This time I will bring you array_combine()arraymergefunctiondetailed explanation of use cases, precautions for using the array_combine() array combination function What are they? The following is a practical case. Let’s take a look.
array_combine() Definition and usage
array_combine() function creates 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.
If one of the arrays is empty, or the two arrays have different numbers of elements, this function returns false.
Syntax
array_combine(array1,array2)
Parameter Description
array1 Required. Specifies the key name.
array2 Required. specified value.
Tips and Comments
Comments: Both parameters must have the same number of elements.
Example, array_combine function application.
<?php $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 )
I believe you have mastered the method after reading the case in this article. For more exciting information, please pay attention to other related articles on the php Chinese website!
Recommended reading:
Detailed explanation of the steps of array_key_exists() function to search array key names
Summary of how to use php array search function
The above is the detailed content of Detailed explanation of use cases of array_combine() array combination function. For more information, please follow other related articles on the PHP Chinese website!