Php Array Function Sequence-array_combine ()-instructions for use of array merging Functions

Source: Internet
Author: User

Array_combine () Definition and usage
The array_combine () function combines two arrays to create a new array. One of the arrays is the key name, and the other 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 is required. Specifies the key name.
Array2 is required. The specified value.

Tips and comments
Note: The two parameters must have the same number of elements.

ExampleCopy codeThe Code is as follows: <? Php
$ 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)

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.