How to learn PHP array

Source: Internet
Author: User
Tags arrays learn php

Definitions and usage

The Array_intersect () function returns an array of intersections of two or more arrays.

The resulting array contains all the values that are in the array of comparisons and all other parameter arrays, and the key name remains unchanged.

Note: Only values are used for comparisons.

Grammar

Array_intersect (Array1,array2,array3 ...)

Parameters

Describe

Array1 required. The first array to compare with the other arrays.

Array2 required. The array to compare with the first array.

Array3 Optional. The array to compare with the first array. can have multiple.

Example

<?php $a 1=array (0=> "Cat",1=> "Dog",2=> "horse"); $a 2=array (3=> "horse",4=> "Dog",5=> "Fish"); Print_r (Array_intersect ($a 1, $a 2));?>

Output:

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

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.