PHP array_diff () and array_diff_key () Functions

Source: Internet
Author: User

Let's take a look at the PHP array_diff () syntax.

Definition and usage
The array_diff () function compares two or more arrays and returns the entry and value of an array from the first array, only when the value is not in any other array.

Syntax

Array_diff (array1, array2, array3 ...)
Parameter description: required by array1. The first array, the other will be required with array2. An array is optional relative to the first array array3. An array is relative to the first array. Tip and note: You can compare the first array with an array, or you like it. Note: Only value is used for comparison. Let's take a look at the instance. <? Php
$ A1 = array (0 => "Cat", 1 => "Dog", 2 => "Horse ");
$ A2 = array (3 => "Horse", 4 => "Dog", 5 => "Fish ");
Print_r (array_diff ($ a1, $ a2 ));
?> Output result. Array ([0] => Cat)

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.