Re: Testing for Current pointer position in array during iteration
| From: | Jochem Maas | Date: | Fri, 29 Aug 2008 21:10:37 +0000 |
| Subject: | Re: Testing for Current pointer position in array during iteration | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-279027@lists.php.net to get a copy of this message | ||
Mark Weaver schreef:
tedd wrote:...
not in the context of foreach() (I'll repeat the oneliner here because tedd's old and has a crap email client ;-): php -r '$r = array("a","b","c"); next($r); $K = key($r); foreach ($r as $k => $v) { echo "$K ", key($r), " $k\n"; }' current() is akin to key() in that they both work on where the array pointer currently is. not that current() returns a key ;-)Try looking at "current" http://www.php.net/current Maybe that will help.
....
Jochem put things back into perspective for me.I'm having that printed on a T-Shirt :-P