rtrim($my_string, ',');
$string = rtrim($string, ',');
$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 ", ";
}
}
echo substr($string, 0, -2);
//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;
}
$p_country= rtrim($p_countrys, ',')