Re: Foreach question

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

 



On 11-07-05 11:46 AM, Louis Huppenbauer wrote:
Just use count($arr) in your for-header, as it get's executed again
for each loop.

<?php
    $arr = array(array('id'=>1), array('id'=>2));
         for($i=0;$i<count($arr);$i++) {
                 echo $arr[$i]['id'];
                 if($i<  6) {
                         $arr[] = array('id' =>  $arr[$i]['id']+1);
                 }
         }
?>


Ok, so the extents are being updated on each pass of the loop :)

Cheers,
Rob.
--
E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.

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