Php-Arrays function-array_combine-uses the values of two Arrays as the keys and values of the new array to create an array.

Source: Internet
Author: User
Array_combine () function [function] combines two arrays to create a new array. one of the arrays is the key name, and the other is the key value. [Scope of use] This function is a new function in php5. Php5. [Syntax] array... SyntaxHighlighter. all ();

Array_combine () function
[Function] combines two arrays to create a new array,
One array is the key name, and the other array value 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 number of elements in the two arrays is different, this function returns false.
[Example]
[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] => value1
[Value4] => value2
)*/

 

 

Taken from zuodefeng's note

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.