1--TEST--
2Test array_diff() function : usage variations  - array with different data types as values
3--FILE--
4<?php
5/*
6 * Test how array_diff() compares indexed arrays containing different
7 * data types as values in place of $arr2
8 */
9
10echo "*** Testing array_diff() : usage variations ***\n";
11
12// Initialise function arguments not being substituted (if any)
13$array = array(1, 2);
14
15//get an unset variable
16$unset_var = 10;
17unset ($unset_var);
18
19//get heredoc
20$heredoc = <<<END
21This is a heredoc
22END;
23
24//array of values to iterate over
25$values = array(
26
27/*1*/"empty array" => array(),
28
29/*2*/
30"int" => array(
31      // int data
32      0,
33      1,
34      12345,
35      -2345),
36
37/*3*/
38"float" => array(
39      // float data
40       10.5,
41       -10.5,
42       12.3456789000e10,
43       12.3456789000E-10,
44       .5),
45
46/*4*/
47"null" => array(
48      // null data
49      NULL,
50      null),
51
52/*5*/
53"boolean" => array(
54      // boolean data
55      true,
56      false,
57      TRUE,
58      FALSE),
59
60/*6*/
61"empty" => array(
62      // empty data
63      "",
64      ''),
65
66/*7*/
67"string" => array(
68      // string data
69      "string",
70      'string',
71      $heredoc),
72
73/*8*/
74"binary" => array(
75       // binary data
76       b"binary",
77       (binary)"binary"),
78
79/*9*/
80"undefined" => array(
81      // undefined data
82      @$undefined_var),
83
84/*10*/
85"unset" => array(
86      // unset data
87      @$unset_var)
88);
89
90// loop through each element of the array for $arr2
91$iterator = 1;
92foreach($values as $value) {
93      echo "\n Iteration: $iterator \n";
94      var_dump( array_diff($array, $value) );
95      $iterator++;
96};
97
98echo "Done";
99?>
100--EXPECT--
101*** Testing array_diff() : usage variations ***
102
103 Iteration: 1
104array(2) {
105  [0]=>
106  int(1)
107  [1]=>
108  int(2)
109}
110
111 Iteration: 2
112array(1) {
113  [1]=>
114  int(2)
115}
116
117 Iteration: 3
118array(2) {
119  [0]=>
120  int(1)
121  [1]=>
122  int(2)
123}
124
125 Iteration: 4
126array(2) {
127  [0]=>
128  int(1)
129  [1]=>
130  int(2)
131}
132
133 Iteration: 5
134array(1) {
135  [1]=>
136  int(2)
137}
138
139 Iteration: 6
140array(2) {
141  [0]=>
142  int(1)
143  [1]=>
144  int(2)
145}
146
147 Iteration: 7
148array(2) {
149  [0]=>
150  int(1)
151  [1]=>
152  int(2)
153}
154
155 Iteration: 8
156array(2) {
157  [0]=>
158  int(1)
159  [1]=>
160  int(2)
161}
162
163 Iteration: 9
164array(2) {
165  [0]=>
166  int(1)
167  [1]=>
168  int(2)
169}
170
171 Iteration: 10
172array(2) {
173  [0]=>
174  int(1)
175  [1]=>
176  int(2)
177}
178Done
179