UK ['d?f] US ['d?f]
abbr.differential differential(of);difference different;differ different;differentiator differentiator
php array_diff() function syntax
Function:Compare the key values ??of two arrays and return the difference
Syntax: array_diff(array1,array2,array3...)
Parameters:
Description | |
Required. The first array to compare with other arrays. | |
Required. The array to compare to the first array. | |
Optional. Additional array to compare with the first array. |
#Description: Returns the difference array of two arrays. This array contains all keys that are in the array being compared, but are not in any of the other parameter arrays. In the returned array, the key names remain unchanged.
php array_diff() function example
<?php $class1 = array("西門"=>"55","滅絕"=>"44","無忌"=>"22"); $class2 = array("西門"=>"54","滅絕"=>"44","無忌"=>"25"); print_r(array_diff($class1,$class2 )); //返回兩個(gè)數(shù)組中不一樣的元素 ?>
Run instance?
Click the "Run instance" button to view the online instance
Output:
Array ( [西門] => 55 [無忌] => 22 )
<?php $per1=array("a"=>"滅絕師太","b"=>"歐陽克","c"=>"西門大官人","d"=>"韋小寶"); $per2=array("e"=>"Peter","f"=>"慕容復(fù)","g"=>"陳近南"); $per3=array("a"=>"滅絕師太","b"=>"歐陽克","h"=>"王重陽"); $result=array_diff($per1,$per2,$per3); print_r($result); ?>
Run Instance?
Click the "Run Instance" button to view the online instance
Output:
Array ( [c] => 西門大官人 [d] => 韋小寶 )