shamuraq Posted August 14 Share Posted August 14 Hi, I have an array that i want to 'echo' in a foreach loop: foreach($numbers as $num){ echo $num.':'; } i need the output to be 459:534:141 instead of 459:534:141:. How do i remove the ':' at the final loop? Thanx in advance. Quote Link to comment https://forums.phpfreaks.com/topic/323028-formatting-echo-from-array/ Share on other sites More sharing options...
Solution Barand Posted August 14 Solution Share Posted August 14 Use join() instead of the foreach loop. echo join(':', $numbers); Quote Link to comment https://forums.phpfreaks.com/topic/323028-formatting-echo-from-array/#findComment-1632587 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.