Example 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
)
link

25% accept rate
You should improve your accept rate! How does accepting an answer work – Styxxy 30 mins ago
feedback

2 Answers

I think str_getcsv() is the function you are looking for; it should do exactly what you want.

link|improve this answer
feedback

Use the str_getcsv function:

$array = str_getcsv('var1, var2, var3, "var4, test, test2", var5, "var6", var7');
link|improve this answer
thanks guys. It works – Quy 32 mins ago
feedback

Your Answer

 
or
required, but never shown
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.