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() :mixed{
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 = dict
["a" => "green", 0 => "yellow", 1 => "red"];
35 $fp = fopen(__FILE__
, "r");
43 $index_array = vec
[1, 2, 3];
44 $assoc_array = dict
['one' => 1, 'two' => 2];
46 //array of values to iterate over
53 'int -12345' => -2345,
57 'float -10.5' => -10.5,
58 'float 12.3456789000e10' => 12.3456789000e10
,
59 'float -12.3456789000e10' => -12.3456789000e10
,
63 'uppercase NULL' => NULL,
64 'lowercase null' => null,
67 'lowercase true' => true,
68 'lowercase false' =>false,
69 'uppercase TRUE' =>TRUE,
70 'uppercase FALSE' =>FALSE,
73 'empty string DQ' => "",
74 'empty string SQ' => '',
77 'string DQ' => "string",
78 'string SQ' => 'string',
79 'mixed case string' => "sTrInG",
80 'heredoc' => $heredoc,
83 'instance of classWithToString' => new classWithToString(),
84 'instance of classWithoutToString' => new classWithoutToString(),
92 // loop through each element of the array for arr1
94 foreach($inputs as $key =>$value) {
96 var_dump( array_diff_uassoc($value, $array2, key_compare_func
<>) );