Re: Testing for Current pointer position in array during iteration

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Mark Weaver schreef:
tedd wrote:

...


Try looking at "current"

http://www.php.net/current

Maybe that will help.

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 ;-)



....

Jochem put things back into perspective for me.

I'm having that printed on a T-Shirt :-P




--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux