1--TEST--
2Test array_diff_assoc() function : basic functionality
3--FILE--
4<?php
5/* Prototype  : array array_diff_assoc(array $arr1, array $arr2 [, array ...])
6 * Description: Returns the entries of $arr1 that have values which are not
7 * present in any of the others arguments but do additional checks whether the keys are equal
8 * Source code: ext/standard/array.c
9 */
10
11/*
12 * Test basic functionality of array_diff_assoc
13 */
14
15echo "*** Testing array_diff_assoc() : basic functionality ***\n";
16$array_default_key = array('one',       2,            'three', '4');
17$array_numeric_key = array(1 => 'one',  2=> 'two',    3 => 4);
18$array_string_key  = array('one' => 1, 'two' => '2', '3' => 'three');
19
20
21
22echo "-- Compare Default keys to numeric keys --\n";
23var_dump(array_diff_assoc($array_default_key, $array_numeric_key));
24var_dump(array_diff_assoc($array_numeric_key, $array_default_key));
25
26
27echo "\n-- Compare Default keys to string keys --\n";
28var_dump(array_diff_assoc($array_default_key, $array_numeric_key));
29var_dump(array_diff_assoc($array_numeric_key, $array_default_key));
30
31
32echo "\n-- Compare numeric keys to string keys --\n";
33var_dump(array_diff_assoc($array_numeric_key, $array_string_key));
34var_dump(array_diff_assoc($array_string_key, $array_numeric_key));
35
36
37echo "Done";
38?>
39--EXPECTF--
40*** Testing array_diff_assoc() : basic functionality ***
41-- Compare Default keys to numeric keys --
42array(3) {
43  [0]=>
44  string(3) "one"
45  [1]=>
46  int(2)
47  [2]=>
48  string(5) "three"
49}
50array(2) {
51  [1]=>
52  string(3) "one"
53  [2]=>
54  string(3) "two"
55}
56
57-- Compare Default keys to string keys --
58array(3) {
59  [0]=>
60  string(3) "one"
61  [1]=>
62  int(2)
63  [2]=>
64  string(5) "three"
65}
66array(2) {
67  [1]=>
68  string(3) "one"
69  [2]=>
70  string(3) "two"
71}
72
73-- Compare numeric keys to string keys --
74array(3) {
75  [1]=>
76  string(3) "one"
77  [2]=>
78  string(3) "two"
79  [3]=>
80  int(4)
81}
82array(3) {
83  ["one"]=>
84  int(1)
85  ["two"]=>
86  string(1) "2"
87  [3]=>
88  string(5) "three"
89}
90Done
91