Nested Loops

Hi all,

I’m having some issues trying to get a nested loops to work correctly so if you could please provide some help that would be brilliant.

The desired outcome is to have the numbers smaller from 1 and biggest at 5.

1 - should = font 10
12 - should = font 12
123 - should = font 14
1234 - should = font 16
12345 - should = font 18

for ($I=1;$I<6;$I++){

for ($num = 1; $num<=$I;$num++)

//$sz=array("10px","12px","14px","16px","18px");
   echo $num;
   }
  echo "<span style='font-size:${sz[$row]}>";
}   

echo “
”;

Thanks for the help.

Regards.

Shouldn’t nest it to achieve that

[php]<?php
$sz=array(“10px”,“12px”,“14px”,“16px”,“18px”);
for ($i=1;$i<6;$i++) { ?>
<?= $i ?>

<?php }[/php]

Thanks for the advice, much appreciated.

I was just wondering which variable would you have to change to get the out to show as >>
1
12
123
1234
12345

instead of

1
2
3
4
5

Regards.

Ah, my bad. Then you need two loops

Sponsor our Newsletter | Privacy Policy | Terms of Service