src/Helper/ArrayHelper.php
public static function assoc($arr, $name, $type = null)
    {
        $ret = [];
        if (empty($arr)) {
            return $ret;
        }
        if ($type == self::GETTER) {
            $method = 'get' . $name;
            foreach ($arr as $elem) {
                $ret[$elem->$method()] = $elem;
            }
        } elseif ($type == self::OBJ) {
            foreach ($arr as $elem) {
                $ret[$elem->$name] = $elem;
            }
        } else {
            foreach ($arr as $elem) {
                $ret[$elem[$name]] = $elem;
            }
        }
        return $ret;
    }
public static function assoc($arr, $name, $type = null)
    {
        $ret = [];
        if (empty($arr)) {
            return $ret;
        }
        if ($type == self::GETTER) {
            $method = 'get' . $name;
            foreach ($arr as $elem) {
                $ret[$elem->$method()] = $elem;
            }
        } elseif ($type == self::OBJ) {
            foreach ($arr as $elem) {
                $ret[$elem->$name] = $elem;
            }
        } else {
            foreach ($arr as $elem) {
                $ret[$elem[$name]] = $elem;
            }
        }
        return $ret;
    }
public static function assoc ( $ arr , $ name , $ type = null ) { $ ret = [ ] ; if ( empty ( $ arr ) ) { return $ ret ; } if ( $ type == self :: GETTER ) { $ method = 'get' . $ name ; foreach ( $ arr as $ elem ) { $ ret [ $ elem -> $ method ( ) ] = $ elem ; } } elseif ( $ type == self :: OBJ ) { foreach ( $ arr as $ elem ) { $ ret [ $ elem -> $ name ] = $ elem ; } } else { foreach ( $ arr as $ elem ) { $ ret [ $ elem [ $ name ] ] = $ elem ; } } return $ ret ; }
Creates associated array

@param array $array
@param string $name
@param string $type
@return array
Creates associated array