Skip to content

Instantly share code, notes, and snippets.

@richlloydmiles
Created September 1, 2014 07:18
Show Gist options
  • Save richlloydmiles/2fd06b9e66c43571841b to your computer and use it in GitHub Desktop.
Save richlloydmiles/2fd06b9e66c43571841b to your computer and use it in GitHub Desktop.
Alternative to counter variable
<!-- use this as oppsed to a $count ++ var -->
<?php
if($id !== end($type[0])){ echo ',';}
?>
<!-- the end() checks if its the last value and reset() checks if it is the first. -->
@richlloydmiles
Copy link
Author

Use this within a foreach loop, its a lot cleaner than a count var for setting first and last element in array values.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment