Last active
December 20, 2017 00:41
-
-
Save ReinierC/985688c245c7b51af0245bf4aab999b1 to your computer and use it in GitHub Desktop.
PHP modulus example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>PHP Modulus example</title> | |
<style>p {font-size: 12px;}.alert {color: red;}</style> | |
</head> | |
<body> | |
<?php | |
function copperLunchbreak(){ | |
for ($i = 1; $i <= 100; $i++){ | |
if($i % 3 == 0 && $i % 5 ==0){ | |
echo "<a class='alert'>$i Attention all officers</a></br>"; | |
} | |
else if($i % 3 == 0){ | |
echo $i." Pizza for lunch<br />"; | |
} | |
else if($i % 5 == 0){ | |
echo $i." Donuts for lunch<br />"; | |
} | |
else { | |
echo $i." Sleeping on the job<br />"; | |
} | |
} | |
} | |
?> | |
<p><?php copperLunchbreak() ?></p> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment