Hello Andi,
there was nothing in this thread that was against adding it besides Sascha
suggestion that following code would do the trick:
function array_has_more($ar) {
if (!is_array($ar)) {
trigger_error("Argument to array_has_more is no array", E_WARNING);
return NULL;
}
next($ar);
$more = key($ar) !== false;
prev($ar);
return $more;
}
Anyway you said that you don't like the name really. Do you have a better
name? If not i'll go with 'array_has_more'.
regards
marcus
Friday, July 4, 2003, 3:56:31 AM, you wrote:
MB> Hello internals,
MB> during my todays work i was again reminded that still one array function is
MB> missing namely array_has_more. This function will return true if there are
MB> more elements in an array and false if not. The real problem is that next()
MB> doesn't work with false.
MB> A diff against PHP 5 is attached. If noone objects i'll commit this later on
MB> friday.
MB> Examle:
MB> <?php
MB> $ar = array(2,1,false,0);
MB> $i = 0;
MB> function show() {
MB> global $ar, $i;
MB> echo "loop: ";var_dump($i++);
MB> echo "curr: ";var_dump(current($ar));
MB> echo "more: ";var_dump(array_has_more($ar));
MB> echo "curr: ";var_dump(current($ar));
MB> echo "next: ";var_dump(next($ar));
MB> echo "\n";
MB> }
MB> show();
MB> show();
MB> show();
MB> show();
MB> show();
MB> show();
?>>
--
Best regards,
Marcus mailto:[EMAIL PROTECTED]
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php