1--TEST-- 2Test array_diff_key() function : usage variation - Passing null,unset and undefined variable indexed array 3--FILE-- 4<?php 5/* Prototype : array array_diff_key(array arr1, array arr2 [, array ...]) 6 * Description: Returns the entries of arr1 that have keys which are not present in any of the others arguments. 7 * Source code: ext/standard/array.c 8 */ 9 10echo "*** Testing array_diff_key() : usage variation ***\n"; 11 12// Initialise function arguments not being substituted (if any) 13$input_array = array(10 => '10', "" => 'empty'); 14 15//get an unset variable 16$unset_var = 10; 17unset ($unset_var); 18 19$input_arrays = array( 20 'null indexed' => array(NULL => 'null 1', null => 'null 2'), 21 'undefined indexed' => array(@$undefined_var => 'undefined'), 22 'unset indexed' => array(@$unset_var => 'unset'), 23); 24 25foreach($input_arrays as $key =>$value) { 26 echo "\n--$key--\n"; 27 // loop through each element of the array for arr1 28 var_dump( array_diff_key($input_array, $value) ); 29 var_dump( array_diff_key($value, $input_array) ); 30} 31?> 32===DONE=== 33--EXPECTF-- 34*** Testing array_diff_key() : usage variation *** 35 36--null indexed-- 37array(1) { 38 [10]=> 39 string(2) "10" 40} 41array(0) { 42} 43 44--undefined indexed-- 45array(1) { 46 [10]=> 47 string(2) "10" 48} 49array(0) { 50} 51 52--unset indexed-- 53array(1) { 54 [10]=> 55 string(2) "10" 56} 57array(0) { 58} 59===DONE===