I’m trying to explode a string with commas, but in the string are some commas I don’t want to get explode, those commas are between " " like: "hey, how are you". I tried multiple things like exploding the " first. So how can I do this?
For example i have this string:
hey,how,are,"yo how,are you?",i'm,good
So the output will be:
array (
0 => hey,
1 => how,
2 => are,
3 => "you how, are you?",
4 => i'm,
5 => good
);
I tried to explode first on " that but I have no idea how.
Use
str_getcsv()for PHP >= 5.3:This prints: