Home  >  Article  >  Backend Development  >  php-Arrays function-array_combine-create a new array using the values ​​​​of two arrays as the keys and values ​​​​of the new array_PHP tutorial

php-Arrays function-array_combine-create a new array using the values ​​​​of two arrays as the keys and values ​​​​of the new array_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 17:51:351372browse

array_combine() function
【Function】 Create a new array by merging two arrays,
One of the arrays is the key name, and the value of the other array is the key value.
【Scope of use】This function is a new function in php5. php5.
【Syntax】 array array_combine(array keys,array values)
keys/required/specified key name values/required/specified value
If one of the arrays is empty, or the two arrays have different numbers of elements, the function returns false.
                                                                                              [php]
                $arr1 = array( "key1" => "value1", "key2" => "value2" );
                $arr2 = array( "key3" => "value3", "key4" => "value4" );
                $arr_combine = array_combine( $arr2, $arr1 );
                 print_r( $arr_combine );
                /*Array
(
[VALUE3] = & GT; Value1
[Value4] = & GT; Value2
)*/

Excerpted from zuodefeng’s notes

http://www.bkjia.com/PHPjc/478194.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/478194.htmlTechArticlearray_combine() function [Function] Create a new array by merging two arrays, one of which is the key name, and the value of another array is the key value. [Scope of use] This function...
Statement:
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