Nested loop

Hi all,

I’m trying to output a nested loop that shows numbers from number 1 being a small font to 12345 being the biggest font but I can’t seem to get it working correctly,see attached code.

1 = font 10

12 = font 12

123 = font 14

1234 = font 16

12345 = font 18

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

<?= $i ?>

<?php } ?>

Regards,

James.

[php]<?php
$sz = array(
“1” => “10px”,
“12” => “12px”,
“123” => “14px”,
“1234” => “16px”,
“12345” => “18px”
);

foreach ($sz as $key => $value)
{
echo "<span style=“font-size:$value”>$key
";
}
?>[/php]

Hi Kevin,

Thanks for all the help.much appreciated.

I’m new to programing and even this small program is way over my head!!
I would rather do maths and physics :slight_smile:

Regards
J.

Sponsor our Newsletter | Privacy Policy | Terms of Service