Suppose that I have a string $var:
$var
//php code $var = \"hello,world,test\"; $exp = explode(\",\",$var);
Now I get the array as
I would have thought json_encode would be the most reliable and simplest way.
E.g.
$var = "hello,world,test"; $exp = explode(",",$var); print json_encode($exp);