Bug #10264 Updated: strange associative array behaviour
| From: | php-bugs at lists dot php dot net | Date: | Sun, 31 Mar 2002 05:00:02 +0000 |
| Subject: | Bug #10264 Updated: strange associative array behaviour | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-3673@lists.php.net to get a copy of this message | ||
ID: 10264
Updated by: php-bugs@lists.php.net
Reported By: shane.wright@ecustomeropinions.com
-Status: Feedback
+Status: No Feedback
Bug Type: Arrays related
Operating System: RedHat 7
PHP Version: 4.0.4pl1
New Comment:
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
Previous Comments:
------------------------------------------------------------------------
[2002-02-26 21:39:40] yohgaki@php.net
s/stiall/still/g
------------------------------------------------------------------------
[2002-02-26 21:39:04] yohgaki@php.net
Is this stiall a issue?
------------------------------------------------------------------------
[2001-05-21 14:08:43] cynic@php.net
IIRC PHP converts numeric strings in array indices to numbers, so array(
"1" => "foo" , "2" => "bar" ) actually creates array(
1 => "foo" , 2 =>
"bar" ). IE the proposed method won't work.
------------------------------------------------------------------------
[2001-05-19 13:06:07] jeroen@php.net
I.M.O. negative integer indices are not supported. It is just a
side-effect of the implementation that it works.
I haven't seen ANY language supporting negative array-indices.
You can use the real assosiative version though:
$data["$i"] = ...
And don't forget to use the same syntax when collecting the data.
------------------------------------------------------------------------
[2001-04-10 12:33:48] shane.wright@ecustomeropinions.com
Not sure if this is a bug or not, but I can't find any
reference to it in the documentation/user comments/FAQs
Basically, if you build an associative(ish) array like
this:
$period = -24;
for ($i=$period; $i<=0; $i++) {
$data[$i] = $myvalues[$anotherindex];
};
It works ok, the array contains (in order) elements with
the inidices -24 to 0.
But, if $period is decreased so that over 25 elements are
introduced, the order goes off...
basically elements with indices -24 to 0 are fine, but all
the other ones come, in order, _after_ index 0.
Any ideas?
Shane
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=10264&edit=1