Created
April 14, 2019 11:19
-
-
Save tomodutch/54b8659bf9d608fcec7b9128e26409fc to your computer and use it in GitHub Desktop.
This file contains 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
<?php | |
function isEven($n) { | |
return $n % 2 == 0; | |
} | |
function isOdd($n) { | |
return isEven($n) === false; | |
} | |
$elements = [1, 2, 3, 4, 5]; | |
?> | |
<table> | |
<tr> | |
<th> | |
# | |
</th> | |
<th> | |
is even? | |
</th> | |
</tr> | |
<?php foreach ($elements as $element): ?> | |
<tr> | |
<td> | |
<?php echo $element; ?> | |
</td> | |
<?php if(isEven($element)): ?> | |
<td> | |
Yes! | |
</td> | |
<?php else: ?> | |
<td> | |
No! | |
</td> | |
<?php endif; ?> | |
</tr> | |
<?php endforeach; ?> | |
</table> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment