Just a note that I'd prefer a different name as well.  I really don't
see the use for this function though.  If you need to see the next
element in the iteration use next(), and then rewind it with prev().

-Sterling

On Sat, 2003-07-05 at 06:57, Marcus Börger wrote:
> 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]
-- 
"A business that makes nothing but money is a poor kind of business." 
    - Henry Ford

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to