Jump to content

[SOLVED] this problem involves count() and a for loop


evanct

Recommended Posts

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?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.