Re: end of array

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

 



Raj Shekhar wrote:
Jeffery Fernandez <forums@xxxxxxxxxxxxxxxxxxxxxx> writes:


Hi all,

I have a foreach loop on an array and within that loop I need to find
if the array has reached the last pointer. I have tried

if (next($row))
{

}

but that advances the pointer. Any tips on finding out if the array
pointer has reached the last element ?


$n_elts = count($myarray);
for ($i=0; $i< $n_elts ; $i++)
{
        if ($i = $n_elts -1)
        {
                echo "On last element";
                break;
        }
        else
        {
                echo "Somwhere in the middle";
        }
}
that's an eternal loop in case you hadn't noticed (*rolls eyes*)

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