Re: Efficency in looping arrays?
| From: | Peter Lauri | Date: | Wed, 17 Nov 2004 13:20:40 +0000 |
| Subject: | Re: Efficency in looping arrays? | ||
| References: | 1 2 3 4 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-202289@lists.php.net to get a copy of this message | ||
Probably, thank you :)
"Pluance" <loveplu@gmail.com> skrev i meddelandet
news:bb8d5e78041117051511460c6b@mail.gmail.com...
> You mean this?
>
> foreach ($arr as $key => $value) {
> echo "\$arr[${key}] = $value";
> }
>
> On Wed, 17 Nov 2004 14:05:23 +0100, Peter Lauri <peter@lauri.se> wrote:
> > Hey :)
> >
> > But what if the array have a unordered keystructure? What your loop do
is
> > to call the value with key $i, or am I wrong? What if the keys are
strings?
> >
> > - Best Of Times
> > /Peter Lauri
> >
> >
> > "Dirk Kredler" <dirk@computication.net> skrev i meddelandet
> > news:200411171348.13856.dirk@computication.net...
> >
> >
> > > hey :)
> > >
> > > i use for this reason:
> > >
> > > for($i= 0, $size= sizeof($arr); $i < $size; $i++) {
> > > echo $arr[$i];
> > > }
> > >
> > > Peter Lauri:
> > > > Best groupmember,
> > > >
> > > > For the moment when I loop an array I use something like this:
> > > >
> > > > reset($arr);
> > > > while($a=each($arr)) {
> > > > echo $a['value'];
> > > > }
> > > >
> > > > But the each() function genereates a array with four elements
> > (0,1,value,
> > > > key), I am only interested in the "value".
> > > >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >