erp/app/Utils/ArrayUtils.php

24 lines
427 B
PHP
Raw Permalink Normal View History

<?php
namespace App\Utils;
class ArrayUtils
{
public static function index(array $array, $name)
{
$indexedArray = [];
if (empty($array)) {
return $indexedArray;
}
foreach ($array as $item) {
if (isset($item[$name])) {
$indexedArray[$item[$name]] = $item;
continue;
}
}
return $indexedArray;
}
}