I have an array serving multiple purpose, sometimes I use it for displaying all records, sometimes I use it for displaying the first record, sometimes I use it for displaying the last record.
For displaying all records, I can use
<?php foreach($array['products'] as $product) { ?>
<li>Name: <?php echo $product['name']; ?>'/></li>
<?php } ?>
For displaying the first record, I can use
<?php $product=reset($array['products']); ?>
<li>Name: <?php echo $product['name']; ?>'/></li>
For displaying the last record, what should I do?