Mantis - Quercus
Viewing Issue Advanced Details
4330 minor always 12-17-10 14:22 01-05-11 20:02
gbruins  
 
normal  
new  
open  
none    
none  
0004330: Multidimensional arrays not working properly
$arr = array();
$arr['one'] = array();
$arr['one']['two'] = 2;
$arr['one']['three'] = 3;
print_r($arr);

Expected result:
Array
(
    [one] => Array
        (
            [two] => 2
            [three] => 3
        )

)


However this is being printed:
Array
(
    [one] => Array
)



Notes
(0004880)
gbruins   
12-17-10 14:31   
this is happening on resin 4.0.13
(0004881)
gbruins   
12-17-10 14:40   
BTW, the problem is not with the print_r() function, as this array will print the expected result:

$test = array('one' => array('two' => 2, 'three' => 3));
print_r($test);

// prints:
Array
(
    [one] => Array
        (
            [two] => 2
            [three] => 3
        )

)
(0004882)
gbruins   
12-17-10 14:42   
I don't believe this was an issue on resin-4.0.10
(0004890)
Craige   
01-05-11 20:02   
@gbruins. I disagree; this is a problem with print_r. Proven through:

$arr = array();
$arr['one'] = array();
$arr['one']['two'] = 2;
$arr['one']['three'] = 3;
var_dump($arr); // <--------

Which results in.....


array(1) {
  ["one"]=>
  &array(2) {
    ["two"]=>
    int(2)
    ["three"]=>
    int(3)
  }
}