1--TEST-- 2Test array_diff() function : usage variations - comparing integers, float 3and string array values 4--FILE-- 5<?php 6/* 7 * Test how array_diff compares integers, floats and strings 8 */ 9 10echo "*** Testing array_diff() : usage variations ***\n"; 11 12$arr_int = array(1, 2, 3); 13$arr_float = array(1.00, 2.00, 3.00); 14$arr_int_str = array('1', '2', '3'); 15$arr_float_str = array('1.00', '2.00', '3.00'); 16 17print "-- Compare integers and floats: --\n"; 18var_dump(array_diff($arr_int, $arr_float)); 19var_dump(array_diff($arr_float, $arr_int)); 20 21 22print "-- Compare integers and strings containing an integers: --\n"; 23var_dump(array_diff($arr_int, $arr_int_str)); 24var_dump(array_diff($arr_int_str, $arr_int)); 25 26print "-- Compare integers and strings containing floats: --\n"; 27var_dump(array_diff($arr_int, $arr_float_str)); 28var_dump(array_diff($arr_float_str, $arr_int)); 29 30print "-- Compare floats and strings containing integers: --\n"; 31 32var_dump(array_diff($arr_float, $arr_int_str)); 33var_dump(array_diff($arr_int_str, $arr_float)); 34 35print "-- Compare floats and strings containing floats: --\n"; 36var_dump(array_diff($arr_float, $arr_float_str)); 37var_dump(array_diff($arr_float_str, $arr_float)); 38 39print "-- Compare strings containing integers and strings containing floats: --\n"; 40var_dump(array_diff($arr_int_str, $arr_float_str)); 41var_dump(array_diff($arr_float_str, $arr_int_str)); 42 43echo "Done"; 44?> 45--EXPECT-- 46*** Testing array_diff() : usage variations *** 47-- Compare integers and floats: -- 48array(0) { 49} 50array(0) { 51} 52-- Compare integers and strings containing an integers: -- 53array(0) { 54} 55array(0) { 56} 57-- Compare integers and strings containing floats: -- 58array(3) { 59 [0]=> 60 int(1) 61 [1]=> 62 int(2) 63 [2]=> 64 int(3) 65} 66array(3) { 67 [0]=> 68 string(4) "1.00" 69 [1]=> 70 string(4) "2.00" 71 [2]=> 72 string(4) "3.00" 73} 74-- Compare floats and strings containing integers: -- 75array(0) { 76} 77array(0) { 78} 79-- Compare floats and strings containing floats: -- 80array(3) { 81 [0]=> 82 float(1) 83 [1]=> 84 float(2) 85 [2]=> 86 float(3) 87} 88array(3) { 89 [0]=> 90 string(4) "1.00" 91 [1]=> 92 string(4) "2.00" 93 [2]=> 94 string(4) "3.00" 95} 96-- Compare strings containing integers and strings containing floats: -- 97array(3) { 98 [0]=> 99 string(1) "1" 100 [1]=> 101 string(1) "2" 102 [2]=> 103 string(1) "3" 104} 105array(3) { 106 [0]=> 107 string(4) "1.00" 108 [1]=> 109 string(4) "2.00" 110 [2]=> 111 string(4) "3.00" 112} 113Done 114