Re: loop inside a loop

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

 



On Thu, Apr 17, 2008 at 6:51 PM, Alan Willsher
<al.willsher@xxxxxxxxxxxxxx> wrote:
> Hi can you put a loop inside a loop?
>
>  what I want to do is have something looping every 1 second and then
>  something else looping once every 10 seconds.
>
>  something like a combination of these two..
>
>  $x = 0;
>  while ($x < 1000) {
>  echo "1";
>  $x++;
>  sleep(1);
>  }
>
>  $y = 0;
>  while ($y < 100) {
>  echo "2";
>  $y++;
>  sleep(10);
>  }
>
>  but at the same time so it would output something like
>
>  1111111111211111111112111111111121111111112
>
>  Thanks
>
<?php
$x = 0;
while ($x < 1000) {
  echo "1";
  $x++;
  if ($x % 10 == 9)
   echo "2";
  sleep(1);
}
?>
:)
-- 
-Casey

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