Posted By

pruntrut on 02/05/12


Tagged

php


Versions (?)

Last Item Foreach


 / Published in: PHP
 

  1. <?php
  2. $array = array('apples','bananas','cranberries','durians');
  3. $last_item = end($array);
  4.  
  5. foreach($array as $item) {
  6. if ($item == $last_item) {
  7. print "I like to eat " . $item;
  8. }
  9. }
  10. ?>

Report this snippet  

You need to login to post a comment.