Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

remove last comma from string php foreach

//dont print last comma after string print using foreach loop

hasComma = false;
foreach ($this->sinonimo as $s){ 
    if (hasComma){ 
        echo ","; 
    }
    echo '<span>'.ucfirst($s->sinonimo).'</span>';
    hasComma=true;
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #remove #comma #string #php #foreach
ADD COMMENT
Topic
Name
3+9 =