Created
May 17, 2017 15:07
-
-
Save bluvertigo/c91fc729e8f1c3083e05cbcfd0304732 to your computer and use it in GitHub Desktop.
Stripping last comma from a foreach loop
This file contains hidden or 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
| <?php | |
| $resultstr = array(); | |
| foreach ($results as $result) { | |
| $resultstr[] = $result->name; | |
| } | |
| echo implode(",",$resultstr); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment