Re: foreach

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

 



You´re right, in my example here i could just use a for loop.

But in my real code it´s better to use foreach.

Thanks for your tip.

-- 
João Cândido de Souza Neto
Curitiba Online
joao@xxxxxxxxxxxxxxxxxxxxx
(41) 3324-2294 (41) 9985-6894
http://www.curitibaonline.com.br

"Brad Bonkoski" <bbonkoski@xxxxxxxxxxxxxx> escreveu na mensagem 
news:452BE401.60308@xxxxxxxxxxxxxxxxx
> João Cândido de Souza Neto wrote:
>> Hello.
>>
>> In the follow code:
>>
>> $numbers=array(1,2,3,4,5);
>> foreach ($numbers as number) {
>>     ...
>> }
>>
>> Inside foreach, could i know if i am in the last element of the array 
>> $numbers?
>>
>>
> Sure, maintain a count in the foreach and then compare to 
> count($numbers)..but why not just use a for loop? 

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