| This article describes the PHP array to find the difference set of methods, with the need for a friend reference. In PHP, find the difference set of arrays. You need to use the difference set function for the array: Array_diff (). The PHP array function Array_diff () returns a value that appears in the first array but not in the other input array. This function is opposite to Array_intersect (). Array Array_diff (array Array1,array array2[,arrayn ...]) Let's look at a simple example:
Banana) ?>
Next, we introduce the method of PHP to take two arrays of difference set. Then look at the definition and usage of the Array_diff () function. The definition and usage of the Array_diff () function returns an array of difference sets for two arrays. The array includes all of the key values in the array being compared, but not in any other parameter array. In the returned array, the key name remains unchanged. Grammar Array_diff (Array1,array2,array3 ... Parameter description array1 required. The first array to compare with the other array. Array2 required. The array to compare with the first array. Array3 is optional. The array to compare with the first array. Tip You can use one or any number of arrays to compare to the first array. Note Only values are used for comparisons. Example:
"Cat",1=> "Dog",2=> "Horse"); $str 2=array (3=> "Horse",4=> "Dog",5=> "Fish"); $result = Array_diff ($str 1, $str 2); Dump ($result); To find array difference set by bbs.it-home.org?>
Output: Array 0=>string ' Cat ' (length=3) |