← All built-ins / array_combine()

array_combine()

array_combine(...$args): mixed

Parameters

NameTypeDescription
$keysarraylist of keys
$valuesarraylist of values (same length)

Return value

Map built from the two lists.

Example

$m = array_combine(["a", "b"], [1, 2]);
echo $m["a"], $m["b"];
12

See also

array_fill_keys()array_flip()