1--TEST-- 2Test array_diff_assoc() function : usage variations - arrays containing referenced variables 3--FILE-- 4<?php 5/* 6 * Tests how array_diff_assoc compares 7 * 1. Referenced variables 8 * 2. Arrays that have been referenced to each other 9 */ 10 11echo "*** Testing array_diff_assoc() : usage variations ***\n"; 12 13$a = 'a'; 14 15$arr1 = array('a', 'b', 'c', $a); 16$arr2 = array('a' => 1, 'b' => 2, 'c' => 3, &$a); 17 18echo "-- Results when \$a = $a: --\n"; 19var_dump(array_diff_assoc($arr1, $arr2)); 20var_dump(array_diff_assoc($arr2, $arr1)); 21 22$a = 4; 23 24echo "-- Results when \$a has been changed to $a: --\n"; 25var_dump(array_diff_assoc($arr1, $arr2)); 26var_dump(array_diff_assoc($arr2, $arr1)); 27 28$arr2 = &$arr1; 29 30echo "-- Results when \$arr2 is referenced to \$arr1 --\n"; 31var_dump(array_diff_assoc($arr1, $arr2)); 32var_dump(array_diff_assoc($arr2, $arr1)); 33 34$arr1 = array('zero' => 'x', 'one' => 'y', 'two' => 'z'); 35 36echo "-- Results when \$arr1 is changed --\n"; 37var_dump(array_diff_assoc($arr1, $arr2)); 38var_dump(array_diff_assoc($arr2, $arr1)); 39 40echo "Done"; 41?> 42--EXPECT-- 43*** Testing array_diff_assoc() : usage variations *** 44-- Results when $a = a: -- 45array(3) { 46 [1]=> 47 string(1) "b" 48 [2]=> 49 string(1) "c" 50 [3]=> 51 string(1) "a" 52} 53array(3) { 54 ["a"]=> 55 int(1) 56 ["b"]=> 57 int(2) 58 ["c"]=> 59 int(3) 60} 61-- Results when $a has been changed to 4: -- 62array(4) { 63 [0]=> 64 string(1) "a" 65 [1]=> 66 string(1) "b" 67 [2]=> 68 string(1) "c" 69 [3]=> 70 string(1) "a" 71} 72array(4) { 73 ["a"]=> 74 int(1) 75 ["b"]=> 76 int(2) 77 ["c"]=> 78 int(3) 79 [0]=> 80 &int(4) 81} 82-- Results when $arr2 is referenced to $arr1 -- 83array(0) { 84} 85array(0) { 86} 87-- Results when $arr1 is changed -- 88array(0) { 89} 90array(0) { 91} 92Done 93