php array_combine() function
Translation results:
UK[kəmˈbaɪn] US[kəmˈbaɪn]
v. To combine; to combine; to have both; to harvest with a combine harvester
n. Combine; combine harvester; combined group; Combined works of art (works of art made up of paintings, collages and Constructivist sculptures)
Third person singular: combines Present participle: combining Past tense: combined Past participle: combined
php array_combine() functionsyntax
Function:Create a new array by merging two arrays, one of which is the key name, and the value of the other array is the key value
Syntax:array_combine(keys,values);
Parameters:
Parameters | Description |
keys | Required. Array of key names. |
values | Required. Key-value array. |
Instructions: Merge two arrays to create a new array, one of which is the key name, and the value of the other array is the key value. The number of elements in the key name array and the key value array must be the same! If one of the arrays is empty, or the two arrays have different numbers of elements, the function returns false.
php array_combine() functionexample
<?php $name=array("西门","灭绝","peter"); $skill=array("吹雪剑法","九阴白骨爪","降龙十八掌"); $desc=array_combine($name,$skill); print_r($desc); ?>
Run instance»
Click the "Run instance" button to view the online instance
Output:
Array ( [西门] => 吹雪剑法 [灭绝] => 九阴白骨爪 [peter] => 降龙十八掌 )