$var = "['test', 'test2', 'test3']";
how do I create a workable array from this in PHP?
I've tried explode($var, ","); but this didn't seem to work, unless something went wrong with that attempt.
I would say that it looks like a job for json_decode, but its not valid json... There is a way to make it valid however:
How to json_decode invalid JSON with apostrophe instead of quotation mark
There is an eval() function in PHP which converts string into PHP statements. The string has to be valid PHP statement.
In your case "['test', 'test2', 'test3']"; is not valid statement. You can use something similar to below syntax. Please note that the $x is in single quotes as $x in double quotes will return the value.
$var = "['test', 'test2', 'test3'];";
eval('$x = ' . $var);
print_r($x);
$myArray = str_getcsv(trim($var, '[]'), ',', "'");