PHP array function sequence array_combine() - Instructions for using the array merge function_PHP tutorial

WBOY
Release: 2016-07-21 15:23:20
Original
1091 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 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 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 )

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/324483.htmlTechArticlearray_combine() Definition and Usage The array_combine() function creates a new array by merging two arrays, one of which The array is the key name, and the value of the other array is the key value. If...
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