Mantis - Quercus
Viewing Issue Advanced Details
3783 major always 11-23-09 19:06 11-23-09 21:59
werelnon  
 
normal  
new 4.0.2  
open  
none    
none  
0003783: array_keys function alters passed in array
The function array_keys works fine on a single dimension array, but a severe issue crops up if used on a sub array of a multi dimension array. For example execute the following code:

<?
$test = array( 'fruit' => array( 'apple' => 'crisp', 'banana' => 'break', 'orange' => 'sour' ));
array_keys( $test['fruit'] );
print_r( $test );
?>

The output of this is:

Array ( [fruit] => Array )

Notes
(0004311)
werelnon   
11-23-09 21:59   
It seems that the array isn't actually altered by calling array_keys, but rather that it makes the subsequent print_r statement not work properly. If you change the test code to:

<?
$test = array( 'fruit' => array( 'apple' => 'crisp', 'banana' => 'break', 'orange' => 'sour' ));
array_keys( $test['fruit'] );
var_dump( $test );
?>

The array looks fine.

So, to clarify the bug here is that calling array_keys on a subarray makes a subsequent call to print_r malfunction.