#35545 [Opn->Bgs]: Bug with some syntaxes in for loops

From: Date: Sun, 04 Dec 2005 12:14:58 +0000
Subject: #35545 [Opn->Bgs]: Bug with some syntaxes in for loops
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-89709@lists.php.net to get a copy of this message
ID: 35545 Updated by: tony2001@php.net Reported By: kervala at jpopdb dot net -Status: Open +Status: Bogus Bug Type: Variables related Operating System: Linux 2.4 PHP Version: 5.1.1 New Comment: The result of this code is unknown in all languages: $years[$i] = $i--; Previous Comments: ------------------------------------------------------------------------ [2005-12-04 13:04:47] kervala at jpopdb dot net Description: ------------ For my site, I used a piece of code which always worked fine. (see below) It's a simple PHP code using a "for" loop and variables manipulation. Reproduce code: --------------- for($i=date("Y")+1; $i>=1970; $years[$i] = $i--); print_r($years); Expected result: ---------------- In all previous PHP versions, it returned : 2006 => 2006, 2005 => 2005, etc... Actual result: -------------- It now returns : 2005 => 2006, 2004 => 2005, etc... ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=35545&edit=1

« previous php.bugs (#89709) next »