Echo a comma on all but the last value? (result from mysql_fetch_array)
<p>How do I echo a comma on all but the last value? Here's my code:</p>

<pre><code>while ($servdescarrayrow = mysql_fetch_array($servdescarray)) {

    ECHO $servdescarrayrow['serv_desc'].",";
}
</code></pre>

<p>Shouldn't this work:</p>

<pre><code>$i = 0;

while ($servdescarrayrow = mysql_fetch_array($servdescarray)) {

    $count = count($servdescarrayrow);
    if ($i &lt; $count) {
    echo $servdescarrayrow['serv_desc'].",";
    $i++;
    }
    else {
        break;
    }
}
</code></pre>
