Reputation: 29
Suppose that I have this string:
var1, var2, var3, "var4, test, test2", var5, "var6", var7
How can I use explode() function to put them into an array like this
Array
(
[0] => var1
[1] => var2
[2] => var3
[3] => var4, test, test2
[4] => var4
[5] => var6
[6] => var7
)
Upvotes: 0
Views: 781
Reputation: 91983
Use the str_getcsv function:
$array = str_getcsv('var1, var2, var3, "var4, test, test2", var5, "var6", var7');
Upvotes: 1
Reputation: 898
I think str_getcsv()
is the function you are looking for; it should do exactly what you want.
Upvotes: 5