The array_combine () function combines two arrays to create a new array. one of the arrays is the key name, and the other array is the key value.
Array_combine () definition and usage
The array_combine () function combines two arrays to create a new array. one of the arrays is the key name, and the other is the key value.
If one of the arrays is empty or the number of elements in the two arrays is different, this function returns false.
Syntax
Array_combine (array1, array2)
Parameter description
Array1 is required. Specifies the key name.
Array2 is required. The specified value.
Tips and comments
Note: The two parameters must have the same number of elements.
Example
The code is as follows:
$ A1 = array ("a", "B", "c", "d ");
$ A2 = array ("Cat", "Dog", "Horse", "Cow ");
Print_r (array_combine ($ a1, $ a2 ));
?>
Output:
Array ([a] => Cat [B] => Dog [c] => Horse [d] => Cow)