Syntax: toDictionary ([keySelector {(v, k) ==> key} [, valueSelector {(v, k) ==> value}]])
The toDictionary method returns an array, a one-to-one dictionary that maps keys to values. If the source sequence contains multiple values with the same key, the result array will only contain the latter value.
public toDictionary ( callable | null $keySelector = null, callable | null $valueSelector = null ) : array | ||
$keySelector | callable | null | {(v, k) ==> key} A function to extract a key from each element. Default: key. |
$valueSelector | callable | null | {(v, k) ==> value} A transform function to produce a result value from each element. Default: value. |
return | array | An array that contains keys and values selected from the input sequence. |