Definition
The array_combine() function creates an array by using the elements from one "keys" array and one "values" array. The "keys" and "values" arrays must have equal number of elements.
Syntax
array_combine(keys, values)
Parameters
Parameter | Description |
---|---|
keys |
Required. Array of keys. |
values |
Required. Array of values. |
Example
<?php
$country = array("USA", "Germany", "Japan");
$city = array("New York", "Berlin", "Tokyo");
print_r(array_combine($country, $city));