Echo a comma on all but the last value? (result from mysql_fetch_array)

后端 未结 11 1980
隐瞒了意图╮
隐瞒了意图╮ 2020-12-21 22:56

How do I echo a comma on all but the last value? Here\'s my code:

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

    ECHO $servdescarrayrow         


        
11条回答
  •  离开以前
    2020-12-21 23:46

    I am wondering why there was a dozen answers to your first question and noone to answer the edited part.

    Nope, it shouldn't work. Because $servdescarrayrow variable represents only one row and you and thus the whole code makes no sense.

    Although you can involve the number of returned records into process and get desired result, I doubt you really need that.

    Not to mention that with the way you echo, you will always have the trailing comma anyway.

提交回复
热议问题