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 $arr1 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 arr1 91$iterator = 1; 92foreach($values as $value) { 93 echo "\n Iteration: $iterator \n"; 94 var_dump( array_diff($value, $array) ); 95 $iterator++; 96}; 97 98echo "Done"; 99?> 100--EXPECT-- 101*** Testing array_diff() : usage variations *** 102 103 Iteration: 1 104array(0) { 105} 106 107 Iteration: 2 108array(3) { 109 [0]=> 110 int(0) 111 [2]=> 112 int(12345) 113 [3]=> 114 int(-2345) 115} 116 117 Iteration: 3 118array(5) { 119 [0]=> 120 float(10.5) 121 [1]=> 122 float(-10.5) 123 [2]=> 124 float(123456789000) 125 [3]=> 126 float(1.23456789E-9) 127 [4]=> 128 float(0.5) 129} 130 131 Iteration: 4 132array(2) { 133 [0]=> 134 NULL 135 [1]=> 136 NULL 137} 138 139 Iteration: 5 140array(2) { 141 [1]=> 142 bool(false) 143 [3]=> 144 bool(false) 145} 146 147 Iteration: 6 148array(2) { 149 [0]=> 150 string(0) "" 151 [1]=> 152 string(0) "" 153} 154 155 Iteration: 7 156array(3) { 157 [0]=> 158 string(6) "string" 159 [1]=> 160 string(6) "string" 161 [2]=> 162 string(17) "This is a heredoc" 163} 164 165 Iteration: 8 166array(2) { 167 [0]=> 168 string(6) "binary" 169 [1]=> 170 string(6) "binary" 171} 172 173 Iteration: 9 174array(1) { 175 [0]=> 176 NULL 177} 178 179 Iteration: 10 180array(1) { 181 [0]=> 182 NULL 183} 184Done 185