1--TEST--
2Test array_diff() function : usage variations - array containing duplicate keys and values
3--FILE--
4<?php
5/* Prototype  : array array_diff(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.
8 * Source code: ext/standard/array.c
9 */
10
11/*
12 * Test that array_diff behaves as expected for comparing:
13 * 1. the order of the array
14 * 2. duplicate values
15 * 3. duplicate key names
16 */
17
18echo "*** Testing array_diff() : usage variations ***\n";
19
20$array_index = array('a', 'b', 'c', 0 => 'd', 'b');   //duplicate key (0), duplicate value (b)
21$array_assoc = array ('2' => 'c',   //same key=>value pair, different order
22                      '1' => 'b',
23                      '0' => 'a',
24                      'b' => '3',   //key and value from array_index swapped
25                      'c' => 2);    //same as above, using integer
26
27var_dump(array_diff($array_index, $array_assoc));
28var_dump(array_diff($array_assoc, $array_index));
29
30echo "Done";
31?>
32--EXPECTF--
33*** Testing array_diff() : usage variations ***
34array(1) {
35  [0]=>
36  string(1) "d"
37}
38array(3) {
39  [0]=>
40  string(1) "a"
41  ["b"]=>
42  string(1) "3"
43  ["c"]=>
44  int(2)
45}
46Done
47