I have a string for example: apple,orange,melon,grape,peach
I want to take the items and display them like this: "apple","orange","melon","grape","peach"
What is the most optimized way to reach this goal?
I have a string for example: apple,orange,melon,grape,peach
I want to take the items and display them like this: "apple","orange","melon","grape","peach"
What is the most optimized way to reach this goal?
$string = 'apple,orange,melon,grape,peach';
$string = explode(',', $string);
$string = '"' . implode('","', $string) . '"';
echo $string;
Compressed:
$string = 'apple,orange,melon,grape,peach';
echo '"' . implode('","', explode(',', $string)) . '"';