ID: 33905 Updated by: [EMAIL PROTECTED] Reported By: s dot lystsev at gmail dot com -Status: Open +Status: Bogus Bug Type: Scripting Engine problem Operating System: Fedora Core release 1 PHP Version: 5.0.4 New Comment:
And you didn't bother trying the latest CVS snapshot? (yes, it is fixed already) Previous Comments: ------------------------------------------------------------------------ [2005-07-28 16:00:04] s dot lystsev at gmail dot com Description: ------------ If I initialize array immediately when declaring it as a class member (see "Reproduce code") and there are some constants among array keys, then the order of array elements is broken. All the elements which have a constant as a key - they are moved to the end of an array. Thus the declared order of elements is broken. If I move initialization of array to some method (e.g. in class constructor) - everything works as expected, array is not reordered. Well, the bug is close to Bug #28072, but there was a talk about static arrays. In my case the array was not static. Reproduce code: --------------- define ('baa', '_a_'); define ('baz', '_b_'); class T { var $test = array( baa => 'xx', 'bbb' => 'x1', 'aaa' => 'x0', 'ccc' => 'x2', baz => 'yy' ); function process() { foreach ($this->test as $x => $y) { echo "$x => $y\n"; } } } $t = new T(); $t->process(); Expected result: ---------------- _a_ => xx bbb => x1 aaa => x0 ccc => x2 _b_ => yy Actual result: -------------- bbb => x1 aaa => x0 ccc => x2 _a_ => xx _b_ => yy ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=33905&edit=1