array_combine
array_combine
array_combine
- It creates an array by using one array for keys and another for its values
Syntax:
array array_combine ( array keys, array values )
It returns an array by using the values from the keys array as keys and the values from the values array as the
corresponding values.
It returns FALSE if the number of elements for each array isn’t equal or if the arrays are empty.
Example:
$a = array(’one’, ‘two’, ‘three’);
$b = array(’1′, ‘2′, ‘3′);
$c = array_combine($a, $b);
print_r($c);
The content in the array $c is
Array
(
[one] => 1
[two] => 2
[three] => 3
)
