Php array function sequence: array_intersect () returns the intersection array of two or more arrays _ PHP Tutorial

Source: Internet
Author: User
Array_intersect () of the php array function sequence returns the intersection array of two or more arrays. Array_intersect () definition and usage the array_intersect () function returns an intersection array of two or more arrays. The result array contains all the results in the compared array and Array_intersect () definition and usage

The array_intersect () function returns the intersection array of two or more arrays.

The result array contains all values in the compared array and all other parameter arrays. The key name remains unchanged.

Note: only values are used for comparison.

Syntax
Array_intersect (array1, array2, array3 ...)
Parameters Description
Array1 Required. The first array to be compared with other arrays.
Array2 Required. The array to be compared with the first array.
Array3 Optional. The array to be compared with the first array. There can be multiple.

Example

The code is as follows:


$ A1 = array (0 => "Cat", 1 => "Dog", 2 => "Horse ");
$ A2 = array (3 => "Horse", 4 => "Dog", 5 => "Fish ");
Print_r (array_intersect ($ a1, $ a2 ));
?>


Output:

Array ([1] => Dog [2] => Horse)

The http://www.bkjia.com/PHPjc/324563.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/324563.htmlTechArticlearray_intersect () definition and usage array_intersect () function returns an intersection array of two or more arrays. The result array contains all the results in the compared array and also appears in all its...

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.