Hi Oskar
2010/1/2 Oskar Eisemuth <[email protected]>:
> Hello
>
> Would it be possible to add functions to know the relative internal array
> position?
>
> I found "[PHP-DEV] RFC array functions" from 2006, but nothing really
> changed.
>
> The need to use next, prev in combination is ridiculous compared to a clean
> array_hasmore or array_pos_islast, as the internals already know this.
> To get an array_valid_position or array_pos_isvalid wouldn't be bad either.
>
> So would it possible to introduce:
>
How about just array_pos() if any. The remaining functions can easily
be implemented in userland like:
function array_pos_isfirst(Array &$array) {
return array_pos($array) == 0;
}
function array_pos_islast(Array &$array) {
return array_pos($array) == (sizeof($array) - 1);
}
I don't think it should be needed to add array_pos_isvalid(), since it
*shouldn't* be possible to point to an invalid position. Rather
"isset($array['key'])" should be used to check if a position is valid.
--
regrads,
Kalle Sommer Nielsen
[email protected]
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php