php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #62268 Multi dimentional Array assigment issue
Submitted: 2012-06-08 20:13 UTC Modified: 2012-06-08 20:21 UTC
From: dmarkweb at gmail dot com Assigned:
Status: Not a bug Package: *General Issues
PHP Version: 5.3.13 OS: CentOS 6.2
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: dmarkweb at gmail dot com
New email:
PHP Version: OS:

 

 [2012-06-08 20:13 UTC] dmarkweb at gmail dot com
Description:
------------
I found it pretty odd and surprisingly.

When I assign a property to multi-dimentional array it doesn't setting the value 
correct.


Test script:
---------------
<?php

$myArray = array();

$myArray['one'] = 1;
$myArray['one']['two'] = 1;
$myArray['one']['two']['three'] = 1;

?>

Expected result:
----------------
Array
(
    [one] => Array
        (
            [two] => Array
                     (
                      [three] => 1
                     )
        )

)

Actual result:
--------------
Array
(
    [one] => 1
)

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-06-08 20:21 UTC] rasmus@php.net
The warning you ignored should take away that surprise:

Warning: Cannot use a scalar value as an array in php shell code on line 1

since $myArray['one'] is a scalar after your first assignment. You then try to 
use that scalar as an array.
 [2012-06-08 20:21 UTC] rasmus@php.net
-Status: Open +Status: Not a bug
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sun Jul 13 21:01:33 2025 UTC