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? 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); 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. 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
Archived
This topic is now archived and is closed to further replies.