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
Release: 2016-07-13 17:51:35
Original
1359 people have browsed it

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...
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!