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