2 /* Prototype : array array_diff_key(array arr1, array arr2 [, array ...])
3 * Description: Returns the entries of arr1 that have keys which are not present in any of the others arguments.
4 * Source code: ext/standard/array.c
8 class classWithToString
10 public function __toString() :mixed{
11 return "Class A object";
15 class classWithoutToString
18 <<__EntryPoint
>> function main(): void
{
19 echo "*** Testing array_diff_key() : usage variation ***\n";
21 // Initialise function arguments not being substituted (if any)
22 $array2 = dict
['green' => 5, 'blue' => 6, 'yellow' => 7, 'cyan' => 8];
23 $array3 = vec
[1, 2, 3, 4, 5];
27 $fp = fopen(__FILE__
, "r");
34 //array of values to iterate over
41 'int -12345' => -12345,
45 'float -10.5' => -10.5,
46 'float 12.3456789000e10' => 12.3456789000e10
,
47 'float -12.3456789000e10' => -12.3456789000e10
,
51 'uppercase NULL' => NULL,
52 'lowercase null' => null,
55 'lowercase true' => true,
56 'lowercase false' =>false,
57 'uppercase TRUE' =>TRUE,
58 'uppercase FALSE' =>FALSE,
61 'empty string DQ' => "",
62 'empty string SQ' => '',
65 'string DQ' => "string",
66 'string SQ' => 'string',
67 'mixed case string' => "sTrInG",
68 'heredoc' => $heredoc,
71 'instance of classWithToString' => new classWithToString(),
72 'instance of classWithoutToString' => new classWithoutToString(),
80 // loop through each element of the array for arr1
81 foreach($inputs as $key =>$value) {
83 var_dump( array_diff_key($value, $array2) );
84 var_dump( array_diff_key($value, $array2, $array3) );