2 /* Prototype : array array_diff_uassoc(array arr1, array arr2 [, array ...], callback key_comp_func)
3 * Description: Computes the difference of arrays with additional index check which is performed by a
4 * user supplied callback function
5 * Source code: ext/standard/array.c
9 class classWithToString
11 public function __toString() {
12 return "Class A object";
16 class classWithoutToString
20 function key_compare_func($a, $b)
25 return ($a > $b)?
1:-1;
27 <<__EntryPoint
>> function main(): void
{
28 echo "*** Testing array_diff_uassoc() : usage variation ***\n";
30 //Initialize variables
31 $array2 = array("a" => "green", "yellow", "red");
33 //get an unset variable
38 $fp = fopen(__FILE__
, "r");
46 $index_array = array (1, 2, 3);
47 $assoc_array = array ('one' => 1, 'two' => 2);
49 //array of values to iterate over
56 'int -12345' => -2345,
60 'float -10.5' => -10.5,
61 'float 12.3456789000e10' => 12.3456789000e10
,
62 'float -12.3456789000e10' => -12.3456789000e10
,
66 'uppercase NULL' => NULL,
67 'lowercase null' => null,
70 'lowercase true' => true,
71 'lowercase false' =>false,
72 'uppercase TRUE' =>TRUE,
73 'uppercase FALSE' =>FALSE,
76 'empty string DQ' => "",
77 'empty string SQ' => '',
80 'string DQ' => "string",
81 'string SQ' => 'string',
82 'mixed case string' => "sTrInG",
83 'heredoc' => $heredoc,
86 'instance of classWithToString' => new classWithToString(),
87 'instance of classWithoutToString' => new classWithoutToString(),
90 'undefined var' => @$undefined_var,
93 'unset var' => @$unset_var,
99 // loop through each element of the array for arr1
101 foreach($inputs as $key =>$value) {
103 var_dump( array_diff_uassoc($value, $array2, "key_compare_func") );