php - Remove last value in a string -
<?php $values = "aaa,bbb,ccc,ddd,";//remove last comma $values = "aaa,bbb,,,";//remove commas after bbb aaa,bbb ?>
how remove commas in example
you can trim "," using below code: use php function rtrim.
<?php $values = "aaa,bbb,ccc,ddd,";//remove last comma echo rtrim($values,','); echo "<br/>"; $values = "aaa,bbb,,,";//remove commas before bbb aaa,bbb echo rtrim($values,','); ?>
Comments
Post a Comment