Re: Testing for Current pointer position in array during iteration

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

 



Dan Joseph schreef:
On Fri, Aug 29, 2008 at 2:40 PM, Mark Weaver <mdw1982@xxxxxxxxxxx> wrote:


...


This may also help as well as Jochem's suggestion:  http://us2.php.net/key

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 2




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