I have a comma separated value like
alpha,beta,charlie
how can I convert it to
"alpha","beta","charlie"
using a single function in php without using str_replace
?
Alternatively to Richard Parnaby-King's function (shorter):
function addQuotes($string) {
return '"'. implode('","', explode(',', $string)) .'"';
}
echo addQuotes('alpha,beta,charlie'); // = "alpha","beta","charlie"