evanct Posted June 7, 2009 Share Posted June 7, 2009 So, I want to echo each value in an array followed by a comma. Except of course I don't want a comma after the last value. Seems straightforward enough, I do this: <?php for ($i=0;$i < (count($links_array)-1);$i++) { echo $links_array[$i].','; } echo $links_array[count($links_array)-1]; ?> no good. The last value doesn't echo at all and I get an "undefined offset" notice. what am i missing here? Quote Link to comment https://forums.phpfreaks.com/topic/161310-solved-this-problem-involves-count-and-a-for-loop/ Share on other sites More sharing options...
.josh Posted June 7, 2009 Share Posted June 7, 2009 echo implode(',',$links_array); Quote Link to comment https://forums.phpfreaks.com/topic/161310-solved-this-problem-involves-count-and-a-for-loop/#findComment-851208 Share on other sites More sharing options...
evanct Posted June 7, 2009 Author Share Posted June 7, 2009 oh. heh. Quote Link to comment https://forums.phpfreaks.com/topic/161310-solved-this-problem-involves-count-and-a-for-loop/#findComment-851212 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.