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