Re: PHP 4.0 Bug #9794: array_keys resets the array pointer and can not be used when looping
| From: | Daniel Beckham | Date: | Fri, 16 Mar 2001 17:20:45 +0000 |
| Subject: | Re: PHP 4.0 Bug #9794: array_keys resets the array pointer and can not be used when looping | ||
| References: | 1 2 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-49087@lists.php.net to get a copy of this message | ||
Awesome. Are you planning to just fix the array_keys function, or will
there be a change as to how the array functions work with the array
pointers?
Thanks,
Daniel Beckham
----- Original Message -----
From: "Andrei Zmievski" <andrei@ispi.net>
To: <danbeck@dealnews.com>
Cc: <php-dev@lists.php.net>
Sent: Friday, March 16, 2001 11:18 AM
Subject: Re: [PHP-DEV] PHP 4.0 Bug #9794: array_keys resets the array
pointer and can not be used when looping
> I'll fix this problem soon. It's even in the TODO.
>
> On Fri, 16 Mar 2001, danbeck@dealnews.com wrote:
> > From: danbeck@dealnews.com
> > Operating system: linux 2.2.16
> > PHP version: 4.0.4pl1
> > PHP Bug Type: Scripting Engine problem
> > Bug description: array_keys resets the array pointer and can not be
used when looping
> >
> > The following code is broken:
> >
> > $arr = array("a", "b", "c");
> > foreach ($arr as $a) {
> > echo "$a<BR>\n";
> > echo max(array_keys($arr));
> > }
> >
> > It stops after the first array element because array_keys resets the
array pointer. (Or at least it's moved to the end...)
> >
> > This is sort of a (repectful) complaint that I have about PHP and they
way it's been written. Arrays are systematically prostituted by the array
functions because each one of them sees fit to reset the array pointer
instead of just working off of a copy, or at the very least, returning the
array pointer to it's previous state.
> >
> > Is there some reason that the array pointer can't be returned to it's
previous state after the array functions are finished with it?
> >
> >
> >
> > --
> > Edit Bug report at: http://bugs.php.net/?id=9794&edit=1”]ïÐmVªH
> > �P÷ÿ
> >
> >
> >
> > --
> > PHP Development Mailing List <http://www.php.net/>
> > To unsubscribe, e-mail: php-dev-unsubscribe@lists.php.net
> > For additional commands, e-mail: php-dev-help@lists.php.net
> > To contact the list administrators, e-mail: php-list-admin@lists.php.net
> >
>
>
>
> -Andrei
> * If Bill Gates had a nickel for every time Windows crashed.. Oh, wait.. *
>
>