i. Display every 10th number in the series in Bold
ii. Display every 3rd number in the series in Italics
iii. Bonus: Underline every Prime number in this series.
See my code. Please correct me. Urgent
<?php
for ($i = 1; $i <= 1000000; ++$i) {
$mod3 = $i % 3;
$mod10 = $i % 10;
$str = '';
if (!$mod3) {
$str = '<p style="color: red;"><u>$i</u></p>';
}
if (!$mod10) {
$str .= '<p style="color: blue;"><u>$i</u></p>';
}
if ($mod3 && $mod10) {
$str .= '<p style="color: purple;"><em>$i</em></p>';
}
echo $str, "\n"; // gives: the color is red, blue, purple
}
?>
<b> This in bold</b> <u>This is underline</u> <i>This is italic</i>
Put the above tags in your code
Why have you used $mod5 = $i %5
t should be $mod10 = $i%10
Thank you. I have adjust the code a little, See Below. Kindly help me check. @camperextraordinaire, Pls be a good teacher. I know you can assist. I will appreciate.
<b> This in bold</b>
<u>This is underline</u>
<i>This is italic</i>
<?php
for ($i = 1; $i <= 1000000; ++$i) {
$mod3 = $i % 3;
$mod10 = $i % 10;
$str = '';
if (!$mod3) {
$str = '<p style="color: red;"><u>$i</u></p>';
}
if (!$mod10) {
$str .= '<p style="color: blue;"><u>$i</u></p>';
}
if ($mod3 && $mod10) {
$str .= '<p style="color: purple;"><em>$i</em></p>';
}
echo $str, "\n"; // gives: the color is red, blue, purple
}
?>
If it so urgent you are in the wrong place, this is not an instant chat, people have lifes and come here to help when they can.
I don’t know much of php, but it seems to me you are italicing both each 3rd and 10th number. you are not using the bold tag anywhere (<b> or <strong> depending on how new is the html you need to use)
Instead you are underlining everything. Ignore the thing about prime numbers if you don’t know what they are, be sure to implement the first two points first, then you can try to implement the bonus part