[PHP] Re: Nested loopa

2012-12-26 Thread Jim Giner
While I fully understand the purpose of the do...while construct, I just 
never get used to seeing it used. (in other langs I had to deal with a 
'repeat...until construct and dis-liked that also).  I pretty much know 
if I'm going to have to deal with a run at least once when I'm coding 
and therefore code appropriately, altho I don't know in what ways I've 
handled it at this very moment.


That said - here is how I would ahve done your exercise.  I just find it 
easier to read one's code when the conditions are declared up front 
rather than after reading thru some lines not knowing when or why they run:


?
$indent = nbsp;nbsp;nbsp;;
$a = 0;
while ($a = 5)
{
echo A = $abr;
$a++;
$b = 0;
while ($b = 10)
{
echo $indent B = $bbr;
$b++;
}
}


To me - so much easier to comprehend at first glance.  As soon as my eye 
comes to a block of code starting with a conditional like 'while', I 
readily see what makes it tick.  Again I see the potential usefulness of 
doing it the other way as you did in your example, but in your case 
there wasn't a need for using 'do...while' since you structured it so 
that there was never a case where you had to force the loop to happen 
regardless of conditions.



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: Nested loopa

2012-12-25 Thread Jim Giner

On 12/25/2012 7:21 PM, Ken Arck wrote:

So I cannot do nested do loops in php?

?php
$a = 0 ;
$b =  0 ;
do {
echo $a\n ;
   do {
 echo $b\n ;
  $b++
 }while($b =10) ;
 $a++;
}while($a = 20) ;
?



Why do you say that?

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php