From:             pages at inrp dot fr
Operating system: Fedora 2 test 2
PHP version:      4.3.6
PHP Bug Type:     Scripting Engine problem
Bug description:  static array with some constant keys will be incorrectly ordered

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 bug report at http://bugs.php.net/?id=28072&edit=1
-- 
Try a CVS snapshot (php4):  http://bugs.php.net/fix.php?id=28072&r=trysnapshot4
Try a CVS snapshot (php5):  http://bugs.php.net/fix.php?id=28072&r=trysnapshot5
Fixed in CVS:               http://bugs.php.net/fix.php?id=28072&r=fixedcvs
Fixed in release:           http://bugs.php.net/fix.php?id=28072&r=alreadyfixed
Need backtrace:             http://bugs.php.net/fix.php?id=28072&r=needtrace
Need Reproduce Script:      http://bugs.php.net/fix.php?id=28072&r=needscript
Try newer version:          http://bugs.php.net/fix.php?id=28072&r=oldversion
Not developer issue:        http://bugs.php.net/fix.php?id=28072&r=support
Expected behavior:          http://bugs.php.net/fix.php?id=28072&r=notwrong
Not enough info:            http://bugs.php.net/fix.php?id=28072&r=notenoughinfo
Submitted twice:            http://bugs.php.net/fix.php?id=28072&r=submittedtwice
register_globals:           http://bugs.php.net/fix.php?id=28072&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=28072&r=php3
Daylight Savings:           http://bugs.php.net/fix.php?id=28072&r=dst
IIS Stability:              http://bugs.php.net/fix.php?id=28072&r=isapi
Install GNU Sed:            http://bugs.php.net/fix.php?id=28072&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=28072&r=float

Reply via email to