PHP array_diff () function

Source: Internet
Author: User
Definition and usage

The array_diff () function returns the number of difference sets of two arrays. This array includes all the key values in the compared array, but not in any other parameter array.

In the returned array, the key name remains unchanged.

Syntax
Array_diff (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.
Tips and comments

Tip:Compare one or more arrays with the first array.

Note:Only values are used for comparison.

Example
<? PHP $ a1 = array (0 => "cat", 1 => "dog", 2 => "horse"); $ A2 = array (3 => "horse ", 4 => "dog", 5 => "fish"); print_r (array_diff ($ A1, $ A2);?>

Output:

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.