php.net |  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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
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
Description:
------------
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++;
print_r($table);
?>



Expected result:
----------------
Array
(
    [0] => Array
        (
            [0] => 0
        )

)

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

)


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-12-16 15:21 UTC] tony2001@php.net
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-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 09:01:28 2024 UTC