1--TEST--
2Test array_diff() function : basic functionality
3--FILE--
4<?php
5/*
6 * Test basic functionality of array_diff
7 */
8
9echo "*** Testing array_diff() : basic functionality ***\n";
10
11//Test indexed array with integers as elements
12$array_int1 = array (1, 2, 3, 4);
13$array_int2 = array (3, 4, 5, 6);
14
15echo "-- Test indexed array with integers as elements --\n";
16var_dump(array_diff($array_int1, $array_int2));
17var_dump(array_diff($array_int2, $array_int1));
18
19
20//Test indexed array with strings as elements
21$array_string1 = array ('one', 'two', 'three', 'four');
22$array_string2 = array ('three', 'four', 'five', 'six');
23
24echo "-- Test indexed array with strings as elements --\n";
25var_dump(array_diff($array_string1, $array_string2));
26var_dump(array_diff($array_string2, $array_string1));
27
28//Test associative array with strings as keys and integers as elements
29$array_assoc_int1 = array ('one' => 1, 'two' => 2, 'three' => 3, 'four' => 4);
30$array_assoc_int2 = array ('three' => 3, 'four' => 4, 'five' => 5, 'six' => 6);
31
32echo "-- Test associative array with strings as keys and integers as elements --\n";
33var_dump(array_diff($array_assoc_int1, $array_assoc_int2));
34var_dump(array_diff($array_assoc_int2, $array_assoc_int1));
35
36//Test associative array with strings as keys and elements
37$array_assoc_str1 = array ('one' => 'un', 'two' => 'deux', 'three' => 'trois', 'four' => 'quatre');
38$array_assoc_str2 = array ('three' => 'trois', 'four' => 'quatre', 'five' => 'cinq', 'six' => 'six');
39
40echo "-- Test associative array with strings as keys and integers as elements --\n";
41var_dump(array_diff($array_assoc_str1, $array_assoc_str2));
42var_dump(array_diff($array_assoc_str2, $array_assoc_str1));
43
44echo "-- Test array_diff with more than 2 arguments --\n";
45var_dump(array_diff($array_int1, $array_int2, $array_string1, $array_string2));
46
47echo "Done";
48?>
49--EXPECT--
50*** Testing array_diff() : basic functionality ***
51-- Test indexed array with integers as elements --
52array(2) {
53  [0]=>
54  int(1)
55  [1]=>
56  int(2)
57}
58array(2) {
59  [2]=>
60  int(5)
61  [3]=>
62  int(6)
63}
64-- Test indexed array with strings as elements --
65array(2) {
66  [0]=>
67  string(3) "one"
68  [1]=>
69  string(3) "two"
70}
71array(2) {
72  [2]=>
73  string(4) "five"
74  [3]=>
75  string(3) "six"
76}
77-- Test associative array with strings as keys and integers as elements --
78array(2) {
79  ["one"]=>
80  int(1)
81  ["two"]=>
82  int(2)
83}
84array(2) {
85  ["five"]=>
86  int(5)
87  ["six"]=>
88  int(6)
89}
90-- Test associative array with strings as keys and integers as elements --
91array(2) {
92  ["one"]=>
93  string(2) "un"
94  ["two"]=>
95  string(4) "deux"
96}
97array(2) {
98  ["five"]=>
99  string(4) "cinq"
100  ["six"]=>
101  string(3) "six"
102}
103-- Test array_diff with more than 2 arguments --
104array(2) {
105  [0]=>
106  int(1)
107  [1]=>
108  int(2)
109}
110Done
111