1--TEST-- 2Test array_intersect_key() function : usage variation - Passing null,unset and undefeined variable indexed array 3--FILE-- 4<?php 5echo "*** Testing array_intersect_key() : usage variation ***\n"; 6 7// Initialise function arguments not being substituted (if any) 8$input_array = array(0 => '0', 1 => '1' , -10 => '-10' , null => 'null'); 9//get an unset variable 10$unset_var = 10; 11unset ($unset_var); 12 13$input_arrays = array( 14 'null indexed' => array(NULL => 'null 1', null => 'null 2'), 15 'undefined indexed' => array(@$undefined_var => 'undefined'), 16 'unset indexed' => array(@$unset_var => 'unset'), 17); 18 19foreach($input_arrays as $key =>$value) { 20 echo "\n--$key--\n"; 21 var_dump( array_intersect_key($input_array, $value) ); 22 var_dump( array_intersect_key($value,$input_array ) ); 23} 24?> 25--EXPECT-- 26*** Testing array_intersect_key() : usage variation *** 27 28--null indexed-- 29array(1) { 30 [""]=> 31 string(4) "null" 32} 33array(1) { 34 [""]=> 35 string(6) "null 2" 36} 37 38--undefined indexed-- 39array(1) { 40 [""]=> 41 string(4) "null" 42} 43array(1) { 44 [""]=> 45 string(9) "undefined" 46} 47 48--unset indexed-- 49array(1) { 50 [""]=> 51 string(4) "null" 52} 53array(1) { 54 [""]=> 55 string(5) "unset" 56} 57