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 $...