I need to see if the numbers 1 – 1000 are divisible and make them the color red. But i’ve got no idea how to.
here’s my code:
JavaScript
x
<?php
for ($i=1; $i<=1000; $i++) {
echo " $i <br/>";
}
if ($i % 7 != 0) {
$i += 7 - ($i % 7);
Advertisement
Answer
JavaScript
<?php
for ($i=1; $i<=1000; $i++) { // iterate through the numbers
if ($i % 7 != 0) // not divisible by 7, just print the number
echo $i." <br/>";
else //divisible by 7, print the number inside a span in order to color the text red
echo '<span style="color:red">'.$i.'</span></br>'
}
?>