I have a list of country as an array .. i want this array in following format to later return it via ajax :-
"india","usa","uk" ..
Used following code to get somewhat i was looking for ..
foreach($country_list as $country) {
$countries .= '"'.$country['label'].'",';
}
problem is it is giving output like "india","usa","uk", ... i.e with trailing comma .
Tried to remove it with
substr_replace($countries, "0", -1);
and
rtrim($countries, ",");
But didnt work ! .. Please help !