Re: Testing for Current pointer position in array during iteration
| From: | Jochem Maas | Date: | Fri, 29 Aug 2008 19:27:03 +0000 |
| Subject: | Re: Testing for Current pointer position in array during iteration | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-279003@lists.php.net to get a copy of this message | ||
Dan Joseph schreef:
On Fri, Aug 29, 2008 at 2:40 PM, Mark Weaver <mdw1982@mdw1982.com> wrote:...
not unless you wan't a headache (re-read the bit about foreach's internal pointer): php -r '$r = array("a","b","c"); next($r); $K = key($r); foreach ($r as $k => $v) { echo "$K ", key($r), " $k\n"; }' outputs: 1 1 0 1 1 1 1 1 2This may also help as well as Jochem's suggestion: http://us2.php.net/key