Skip to content

Instantly share code, notes, and snippets.

@lukearmstrong
Created April 24, 2012 10:47
Show Gist options
  • Save lukearmstrong/2478724 to your computer and use it in GitHub Desktop.
Save lukearmstrong/2478724 to your computer and use it in GitHub Desktop.
<?php
// Controller
$customers = array(
'alan',
'luke'
);
// Imagine $orders may be undefined, null or false.
$orders = null;
?>
<? // View ?>
<h2>Customers</h2>
<? if (isset($customers) && is_array($customers) && !empty($customers)): ?>
<ul>
<? foreach ($customers as $customer): ?>
<li><?= $customer ?></li>
<? endforeach; ?>
</ul>
<? else: ?>
<p>No customers found</p>
<? endif; ?>
<h2>Orders</h2>
<? if (isset($orders) && is_array($orders) && !empty($orders)): ?>
<ul>
<? foreach ($orders as $order): ?>
<li><?= $order ?></li>
<? endforeach; ?>
</ul>
<? else: ?>
<p>No orders found</p>
<? endif; ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment