public static function toMap(array $elements, $keyFunction, $valueFunction = null)
    {
        if ($valueFunction == null) {
            $valueFunction = Functions::identity();
        }

        $keys = array_map($keyFunction, $elements);
        $values = array_map($valueFunction, $elements);
        return empty($keys) ? [] : array_combine($keys, $values);
    }
public static function toMap(array $elements, $keyFunction, $valueFunction = null)
    {
        if ($valueFunction == null) {
            $valueFunction = Functions::identity();
        }

        $keys = array_map($keyFunction, $elements);
        $values = array_map($valueFunction, $elements);
        return empty($keys) ? [] : array_combine($keys, $values);
    }
public static function toMap ( array $ elements , $ keyFunction , $ valueFunction = null ) { if ( $ valueFunction == null ) { $ valueFunction = Functions :: identity ( ) ; } $ keys = array_map ( $ keyFunction , $ elements ) ; $ values = array_map ( $ valueFunction , $ elements ) ; return empty ( $ keys ) ? [ ] : array_combine ( $ keys , $ values ) ; }
This method creates associative array using key and value functions on array elements.

Example:
<code>
$array = range(1, 2);
$map = Arrays::toMap($array, function ($elem) {
return $elem * 10;
}, function ($elem) {
return $elem + 1;
});
</code>
Result:
<code>
Array
(
[10] => 2
[20] => 3
)
</code>

@param array $elements
@param callable $keyFunction
@param callable|null $valueFunction
@return array
This method creates associative array using key and value functions on array elements .