Created
September 1, 2014 07:18
-
-
Save richlloydmiles/2fd06b9e66c43571841b to your computer and use it in GitHub Desktop.
Alternative to counter variable
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- 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. --> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Use this within a foreach loop, its a lot cleaner than a count var for setting first and last element in array values.