Re: Foreach
| From: | Nathan Nobbe | Date: | Wed, 23 Jan 2008 05:58:44 +0000 |
| Subject: | Re: Foreach | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-267896@lists.php.net to get a copy of this message | ||
On Jan 18, 2008 5:24 PM, Richard Lynch <ceo@l-i-e.com> wrote:
> If you are trying to keep the names and orders in "parallel" you need
> to do something not unlike:
>
> while (list($key, $name) = each($names)){
> $order = $orders[$key];
> $query = "update whatever set order = $order where name = '$name'";
> }
just as a mention; spl has a DualIterator class that would be perfect for
this
situation. i hesitate to mention it though, since ive not found it in any
php
version. its there in the doc, but not in actual php; what a shame.
http://www.php.net/~helly/php/ext/spl/classDualIterator.html
i can only expect well see it in a subsequent version; that there is a
reason
its not yet made it..
-nathan