Skip to content

Instantly share code, notes, and snippets.

@tomodutch
Created April 14, 2019 11:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tomodutch/54b8659bf9d608fcec7b9128e26409fc to your computer and use it in GitHub Desktop.
Save tomodutch/54b8659bf9d608fcec7b9128e26409fc to your computer and use it in GitHub Desktop.
<?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