src/Panda/Support/Helpers/ArrayHelper.php
public static function toKeyValue($collection, $key, $value, $useDotSyntax = false)
    {
        $keyValueArray = [];
        foreach ($collection as $item) {
            $itemArray = is_array($item) ? $item : (method_exists($item, 'toArray') ? $item->toArray() : []);
            $keyValue = self::get($itemArray, $key, null, $useDotSyntax);
            $keyValueArray[$keyValue] = $itemArray[$value];
        }

        return $keyValueArray;
    }
public static function toKeyValue($collection, $key, $value, $useDotSyntax = false)
    {
        $keyValueArray = [];
        foreach ($collection as $item) {
            $itemArray = is_array($item) ? $item : (method_exists($item, 'toArray') ? $item->toArray() : []);
            $keyValue = self::get($itemArray, $key, null, $useDotSyntax);
            $keyValueArray[$keyValue] = $itemArray[$value];
        }

        return $keyValueArray;
    }
public static function toKeyValue ( $ collection , $ key , $ value , $ useDotSyntax = false ) { $ keyValueArray = [ ] ; foreach ( $ collection as $ item ) { $ itemArray = is_array ( $ item ) ? $ item : ( method_exists ( $ item , 'toArray' ) ? $ item -> toArray ( ) : [ ] ) ; $ keyValue = self :: get ( $ itemArray , $ key , null , $ useDotSyntax ) ; $ keyValueArray [ $ keyValue ] = $ itemArray [ $ value ] ; } return $ keyValueArray ; }
Return the array in a key-value form, based on the
given parameters for key and value.

@param array|object[] $collection
@param string         $key
@param string         $value
@param bool           $useDotSyntax

@return array
Return the array in a key - value form based on the given parameters for key and value .