2 /* Prototype : array array_diff_assoc(array $arr1, array $arr2 [, array ...])
3 * Description: Returns the entries of $arr1 that have values which are not
4 * present in any of the others arguments but do additional checks whether the keys are equal
5 * Source code: ext/standard/array.c
9 * Test how array_diff_assoc behaves
10 * 1. When comparing an array that has similar elements
11 * but has been created in a different order
12 * 2. When doing a strict comparison of string representation
15 echo "*** Testing array_diff_assoc() : usage variations ***\n";
17 $array = array ('zero',
19 'two' => 2.00000000000001);
23 //default keys => string values
24 /*1*/ array('2.00000000000001', '1', 'zero', 'a'),
26 //numeric keys => string values
27 /*2*/ array(2 => '2.00000000000001',
32 //string keys => string values
33 /*3*/ array('2' => '2.00000000000001',
38 //default keys => numeric values
41 //numeric keys => numeric values
46 //string keys => numeric values
47 /*6*/ array('two' => 2,
51 //defualt keys => float values
52 /*7*/ array(2.00000000000001, 1.00, 0.01E-9),
54 //numeric keys => float values
55 /*8*/ array(2 => 2.00000000000001,
59 //string keys => float values
60 /*9*/ array ('two' => 2.00000000000001,
65 // loop through each element of $inputs to check the behavior of array_diff_assoc
67 foreach($inputs as $input) {
68 echo "\n-- Iteration $iterator --\n";
69 var_dump(array_diff_assoc($array, $input));
70 var_dump(array_diff_assoc($input, $array));