1--TEST-- 2Test array_diff_assoc() function : usage variations - compare integers, floats and strings 3--FILE-- 4<?php 5/* 6 * Test how array_diff_assoc compares integers, floats and string 7 */ 8 9echo "*** Testing array_diff_assoc() : usage variations ***\n"; 10$arr_default_int = array(1, 2, 3, 'a'); 11$arr_float = array(0 => 1.00, 1 => 2.00, 2 => 3.00, 'b'); 12$arr_string = array('1', '2', '3', 'c'); 13$arr_string_float = array('0' => '1.00', '1.00' => '2.00', '2.00' => '3.00', 'd'); 14 15echo "-- Result of comparing integers and floating point numbers: --\n"; 16var_dump(array_diff_assoc($arr_default_int, $arr_float)); 17var_dump(array_diff_assoc($arr_float, $arr_default_int)); 18 19echo "-- Result of comparing integers and strings containing an integers : --\n"; 20var_dump(array_diff_assoc($arr_default_int, $arr_string)); 21var_dump(array_diff_assoc($arr_string, $arr_default_int)); 22 23echo "-- Result of comparing integers and strings containing floating points : --\n"; 24var_dump(array_diff_assoc($arr_default_int, $arr_string_float)); 25var_dump(array_diff_assoc($arr_string_float, $arr_default_int)); 26 27echo "-- Result of comparing floating points and strings containing integers : --\n"; 28var_dump(array_diff_assoc($arr_float, $arr_string)); 29var_dump(array_diff_assoc($arr_string, $arr_float)); 30 31echo "-- Result of comparing floating points and strings containing floating point: --\n"; 32var_dump(array_diff_assoc($arr_float, $arr_string_float)); 33var_dump(array_diff_assoc($arr_string_float, $arr_float)); 34 35echo "-- Result of comparing strings containing integers and strings containing floating points : --\n"; 36var_dump(array_diff_assoc($arr_string, $arr_string_float)); 37var_dump(array_diff_assoc($arr_string_float, $arr_string)); 38 39echo "-- Result of comparing more than two arrays: --\n"; 40var_dump(array_diff_assoc($arr_default_int, $arr_float, $arr_string, $arr_string_float)); 41 42echo "Done"; 43?> 44--EXPECT-- 45*** Testing array_diff_assoc() : usage variations *** 46-- Result of comparing integers and floating point numbers: -- 47array(1) { 48 [3]=> 49 string(1) "a" 50} 51array(1) { 52 [3]=> 53 string(1) "b" 54} 55-- Result of comparing integers and strings containing an integers : -- 56array(1) { 57 [3]=> 58 string(1) "a" 59} 60array(1) { 61 [3]=> 62 string(1) "c" 63} 64-- Result of comparing integers and strings containing floating points : -- 65array(4) { 66 [0]=> 67 int(1) 68 [1]=> 69 int(2) 70 [2]=> 71 int(3) 72 [3]=> 73 string(1) "a" 74} 75array(4) { 76 [0]=> 77 string(4) "1.00" 78 ["1.00"]=> 79 string(4) "2.00" 80 ["2.00"]=> 81 string(4) "3.00" 82 [1]=> 83 string(1) "d" 84} 85-- Result of comparing floating points and strings containing integers : -- 86array(1) { 87 [3]=> 88 string(1) "b" 89} 90array(1) { 91 [3]=> 92 string(1) "c" 93} 94-- Result of comparing floating points and strings containing floating point: -- 95array(4) { 96 [0]=> 97 float(1) 98 [1]=> 99 float(2) 100 [2]=> 101 float(3) 102 [3]=> 103 string(1) "b" 104} 105array(4) { 106 [0]=> 107 string(4) "1.00" 108 ["1.00"]=> 109 string(4) "2.00" 110 ["2.00"]=> 111 string(4) "3.00" 112 [1]=> 113 string(1) "d" 114} 115-- Result of comparing strings containing integers and strings containing floating points : -- 116array(4) { 117 [0]=> 118 string(1) "1" 119 [1]=> 120 string(1) "2" 121 [2]=> 122 string(1) "3" 123 [3]=> 124 string(1) "c" 125} 126array(4) { 127 [0]=> 128 string(4) "1.00" 129 ["1.00"]=> 130 string(4) "2.00" 131 ["2.00"]=> 132 string(4) "3.00" 133 [1]=> 134 string(1) "d" 135} 136-- Result of comparing more than two arrays: -- 137array(1) { 138 [3]=> 139 string(1) "a" 140} 141Done 142