Question : remove last comma from string php
Answered by : indian-gooner
rtrim($my_string, ',');
Source : https://stackoverflow.com/questions/15408691/how-do-i-remove-the-last-comma-from-a-string-using-php | Last Update : Thu, 19 Nov 20
Question : remove comma from last item of loop php
Answered by : yeasin-arafat-783pljfpna57
$animels = array("Dog", "Cat", "Tiger", "Lion", "Cow");
$count_animel = count($animels);
$set_count = 0;
foreach ($animels as $animel) { echo $animel; $set_count = $set_count + 1; if ($set_count < $count_animel) { echo ", "; }
}
Source : | Last Update : Sat, 27 Aug 22
Question : php remove last character from string if comma
Answered by : geeky-bravo
$string = rtrim($string, ',');
Source : https://stackoverflow.com/questions/1642698/how-do-i-remove-a-comma-off-the-end-of-a-string | Last Update : Wed, 01 Jul 20
Question : remove last comma from string php foreach
Answered by : muhammad-waseem
//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 : https://stackoverflow.com/questions/19935405/removing-last-comma-from-a-foreach-loop | Last Update : Wed, 24 Nov 21
Question : remove last comma php
Answered by : faheem-mehdi
$p_country= rtrim($p_countrys, ',')
Source : | Last Update : Sat, 27 Aug 22