cosmic wonder php array function sequence array_combine - Instructions for using array merging function

WBOY
Release: 2016-07-29 08:47:05
Original
1353 people have browsed it

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 number of elements in the two arrays is different, this function returns false.
Syntax
array_combine(array1,array2)
Parameter Description
array1 Required. Specifies the key name.
array2 required. specified value.
Tips and Notes
Note: Both parameters must have the same number of elements.
Example

Copy code 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 )

The above introduces the cosmic wonder php array function sequence array_combine - the instructions for the use of the array merging function, including the content of cosmic wonder. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!