#28072 [Opn->Ver]: static array with some constant keys will be incorrectly ordered

From: Date: Sun, 25 Apr 2004 16:23:16 +0000
Subject: #28072 [Opn->Ver]: static array with some constant keys will be incorrectly ordered
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-58732@lists.php.net to get a copy of this message
ID: 28072 Updated by: iliaa@php.net Reported By: pages at inrp dot fr -Status: Open +Status: Verified Bug Type: Scripting Engine problem Operating System: Fedora 2 test 2 -PHP Version: 4.3.6 +PHP Version: 4.3.6, 5.0.0RC2 Previous Comments: ------------------------------------------------------------------------ [2004-04-20 07:54:00] pages at inrp dot fr Description: ------------ Initialising a static associative array using constants as keys will give an incorrectly ordered array. Apparently, elements with constant keys will always appear AFTER elements without constant keys. Reproduce code: --------------- <?php define("FIRST_KEY", "a"); define("THIRD_KEY", "c"); function test() { static $arr = array( FIRST_KEY => "111", "b" => "222", THIRD_KEY => "333", "d" => "444" ); print_r($arr); } test(); ?> Expected result: ---------------- Array ( [a] => 111 [b] => 222 [c] => 333 [d] => 444 ) Actual result: -------------- Array ( [b] => 222 [d] => 444 [a] => 111 [c] => 333 ) ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=28072&edit=1

« previous php.bugs (#58732) next »