|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2001-03-16 12:29 UTC] sniper@php.net
[2001-03-16 14:35 UTC] andrei@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 25 08:00:01 2025 UTC |
The following code is broken: $arr = array("a", "b", "c"); foreach ($arr as $a) { echo "$a<BR>\n"; echo max(array_keys($arr)); } It stops after the first array element because array_keys resets the array pointer. (Or at least it's moved to the end...) This is sort of a (repectful) complaint that I have about PHP and they way it's been written. Arrays are systematically prostituted by the array functions because each one of them sees fit to reset the array pointer instead of just working off of a copy, or at the very least, returning the array pointer to it's previous state. Is there some reason that the array pointer can't be returned to it's previous state after the array functions are finished with it?