summaryrefslogtreecommitdiff
path: root/ext/standard/tests/array/array_diff_assoc_basic.phpt
blob: 92be6735016606a053eb2eadabadd43dcad080ce (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
--TEST--
Test array_diff_assoc() function : basic functionality
--FILE--
<?php
/* Prototype  : array array_diff_assoc(array $arr1, array $arr2 [, array ...])
 * Description: Returns the entries of $arr1 that have values which are not
 * present in any of the others arguments but do additional checks whether the keys are equal
 * Source code: ext/standard/array.c
 */

/*
 * Test basic functionality of array_diff_assoc
 */

echo "*** Testing array_diff_assoc() : basic functionality ***\n";
$array_default_key = array('one',       2,            'three', '4');
$array_numeric_key = array(1 => 'one',  2=> 'two',    3 => 4);
$array_string_key  = array('one' => 1, 'two' => '2', '3' => 'three');



echo "-- Compare Default keys to numeric keys --\n";
var_dump(array_diff_assoc($array_default_key, $array_numeric_key));
var_dump(array_diff_assoc($array_numeric_key, $array_default_key));


echo "\n-- Compare Default keys to string keys --\n";
var_dump(array_diff_assoc($array_default_key, $array_numeric_key));
var_dump(array_diff_assoc($array_numeric_key, $array_default_key));


echo "\n-- Compare numeric keys to string keys --\n";
var_dump(array_diff_assoc($array_numeric_key, $array_string_key));
var_dump(array_diff_assoc($array_string_key, $array_numeric_key));


echo "Done";
?>
--EXPECT--
*** Testing array_diff_assoc() : basic functionality ***
-- Compare Default keys to numeric keys --
array(3) {
  [0]=>
  string(3) "one"
  [1]=>
  int(2)
  [2]=>
  string(5) "three"
}
array(2) {
  [1]=>
  string(3) "one"
  [2]=>
  string(3) "two"
}

-- Compare Default keys to string keys --
array(3) {
  [0]=>
  string(3) "one"
  [1]=>
  int(2)
  [2]=>
  string(5) "three"
}
array(2) {
  [1]=>
  string(3) "one"
  [2]=>
  string(3) "two"
}

-- Compare numeric keys to string keys --
array(3) {
  [1]=>
  string(3) "one"
  [2]=>
  string(3) "two"
  [3]=>
  int(4)
}
array(3) {
  ["one"]=>
  int(1)
  ["two"]=>
  string(1) "2"
  [3]=>
  string(5) "three"
}
Done