|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #35709 array key assignation
Submitted: 2005-12-16 15:15 UTC Modified: 2005-12-16 15:26 UTC
From: ait-ali dot mohamed at laposte dot net Assigned:
Status: Not a bug Package: Arrays related
PHP Version: 5.1.1 OS: WIN 2K
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: ait-ali dot mohamed at laposte dot net
New email:
PHP Version: OS:


 [2005-12-16 15:15 UTC] ait-ali dot mohamed at laposte dot net
It seems to be an bas assignation for the array.
The engine begins to increment the variable, before
assign in the array's key.

Reproduce code:
$table = array();
$i = 0;
$table [$i][0] = $i++;

Expected result:
    [0] => Array
            [0] => 0


Actual result:
    [1] => Array
            [0] => 0



Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2005-12-16 15:21 UTC]
The behaviour of such code is undefined in all languages I know of and may vary depending on the optimization level used.
 [2005-12-16 15:26 UTC] ait-ali dot mohamed at laposte dot net
But this code works in previous versions (5.0.0, 4.3.9, 4.3.8), without change anything in optimization.
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Wed Oct 20 19:03:32 2021 UTC