2 /* Prototype : array array_udiff_assoc(array arr1, array arr2 [, array ...], callback key_comp_func)
3 * Description: Returns the entries of arr1 that have values which are not present in any of the others arguments but do additional checks whether the keys are equal. Keys are compared by user supplied function.
4 * Source code: ext/standard/array.c
8 echo "*** Testing array_udiff_assoc() : usage variation ***\n";
10 // Initialise function arguments not being substituted (if any)
14 //get an unset variable
18 // define some classes
19 class classWithToString
21 public function __toString() {
22 return "Class A object";
26 class classWithoutToString
36 $index_array = array (1, 2, 3);
37 $assoc_array = array ('one' => 1, 'two' => 2);
39 //array of values to iterate over
46 'int -12345' => -2345,
50 'float -10.5' => -10.5,
51 'float 12.3456789000e10' => 12.3456789000e10
,
52 'float -12.3456789000e10' => -12.3456789000e10
,
56 'empty array' => array(),
57 'int indexed array' => $index_array,
58 'associative array' => $assoc_array,
59 'nested arrays' => array('foo', $index_array, $assoc_array),
62 'uppercase NULL' => NULL,
63 'lowercase null' => null,
66 'lowercase true' => true,
67 'lowercase false' =>false,
68 'uppercase TRUE' =>TRUE,
69 'uppercase FALSE' =>FALSE,
72 'empty string DQ' => "",
73 'empty string SQ' => '',
76 'string DQ' => "string",
77 'string SQ' => 'string',
78 'mixed case string' => "sTrInG",
79 'heredoc' => $heredoc,
82 'instance of classWithToString' => new classWithToString(),
83 'instance of classWithoutToString' => new classWithoutToString(),
86 'undefined var' => @$undefined_var,
89 'unset var' => @$unset_var,
92 // loop through each element of the array for key_comp_func
94 foreach($inputs as $key =>$value) {
96 var_dump( array_udiff_assoc($arr1, $arr2, $value) );