Precautions for the array_diff function, array_diff function _ PHP Tutorial

Source: Internet
Author: User
Precautions for the array_diff function: array_diff function. Precautions for the array_diff function: array_diff: arrayarray_diff (array $ array1, array $ array2 [, array $...]) compared to the notes returned from the arr array_diff function, the array_diff function

Array_diff-calculate the difference set of the array

Note:

ArrayArray_diff(Array$array1, Array$array2[, Array$...]) Returnsarray1But notarray2And any other parameter values in the array. Note that the key name remains unchanged.

Note: This function only checks one dimension in a multi-dimensional array. If you want to write another function for a deeper dimension, you need to write a function for a deeper dimension.

  

 $ Value1) {if (array_key_exists ($ key1, $ array2) {if (is_array ($ value1) {$ diff = array_recursive_diff ($ value1, $ array2 [$ key1]); if (count ($ diff) {$ result [$ key1] = $ diff ;}} else {if ($ value1! = $ Array2 [$ key1]) {$ result [$ key1] = $ value1 ;}} else {$ result [$ key1] = $ value1 ;}} return $ result;} $ result = array_recursive_diff ($ array1, $ array2); echo'
'; Var_dump ($ result); if (empty ($ result) {echo 'identical';} else {echo 'completely different ';}

  

  

  

Array_diff: array array_diff (array $ array1, array $ array2 [, array $...

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.