php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #36274 Incorrect handling of multi-dimensional array increments
Submitted: 2006-02-03 17:22 UTC Modified: 2006-04-03 13:01 UTC
From: micheal dot winger at gmail dot com Assigned:
Status: Not a bug Package: Feature/Change Request
PHP Version: 5.1.2 OS: Windows XP Home
Private report: No CVE-ID: None
 [2006-02-03 17:22 UTC] micheal dot winger at gmail dot com
Description:
------------
When working with multi-dimensional arrays without keys.. it ignores the 2-nd dimension and only increments the first.

Reproduce code:
---------------
$array[][]="blah";
$array[][]="2nd";

print_r($array);

Expected result:
----------------
I expect to see this on the website:

Array ( 
[0] => Array ( [0] => blah ) 
[0] => Array ( [1] => 2nd ) 
)

Actual result:
--------------
Array ( 
[0] => Array ( [0] => blah ) 
[1] => Array ( [0] => 2nd ) 
)

Notice that it is only incrementing the first array. I feel this is a problem since you can do $array[][] in the code, but then it renders useless if you want to have more than one value in the 2nd array, making it impossible to use this method.

If possible, make it work like the expected result, and then add a small function just to jump the first array up.. but give support for higher than 2d arrays, allowing the user to specify which layer the user wants to increment.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-04-03 13:01 UTC] tony2001@php.net
Expected behaviour.
And I really doubt it's going to change ever, since it would be an unreasonable BC break.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed May 01 23:01:28 2024 UTC