Removing last comma from a foreach loop [duplicate]
I'm using a foreach loop to echo out some values from my database and separating each of them by commas. I don't know how to remove the last comma it adds on the last value. My code is pretty simple, but I just can't seem to find the correct way of doing this: foreach ($this->sinonimo as $s){ echo '<span>'.ucfirst($s->sinonimo).',</span>'; }
0 upvotes
View original discussion ↗
Comments
Sign in or sign up to comment and upvote.
No comments yet.