There are a lot of array functions that can be mastered slowly one at a time. Now let's do an introduction to the Array_combine function. Its function is to put two arrays one by the array key name, one by the array value group to synthesize the new array.
The Array_combine () function in PHP is detailed
A new array is created by merging two arrays, one of which is the key name and the other array element is the key value:
<?php$fname=array ("Peter", "Ben", "Joe"), $age =array ("n", "PNs", "a"), $c =array_combine ($fname, $age);p Rint_r ($c) ;? >
Definition and usage
The Array_combine () function creates a new array by merging two arrays, one of which is the key name and the other element is the key value.
Note: Key an array groups and key-value arrays must have the same number of elements!
Grammar
Array_combine (keys,values);
Parameter description
Keys required. Specifies the key name of the array.
values are required. Specifies the key value of the array.
Technical details return value:
Returns the merged array. Returns FALSE if the number of elements in the two array is different.
PHP version: 5+ update log:
Before PHP 5.4, if the array is empty, the e_warning level error is reported and FALSE is returned.