#35709 [Opn->Bgs]: array key assignation

From: Date: Fri, 16 Dec 2005 14:21:33 +0000
Subject: #35709 [Opn->Bgs]: array key assignation
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-90545@lists.php.net to get a copy of this message
ID: 35709 Updated by: tony2001@php.net Reported By: ait-ali dot mohamed at laposte dot net -Status: Open +Status: Bogus Bug Type: Arrays related Operating System: WIN 2K PHP Version: 5.1.1 New Comment: The behaviour of such code is undefined in all languages I know of and may vary depending on the optimization level used. Previous Comments: ------------------------------------------------------------------------ [2005-12-16 15:15:11] 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 ) ) ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=35709&edit=1

« previous php.bugs (#90545) next »