How to convert a string in Php to an array of that string?


If I have a string variable like:

$var = ‘usa, can, aus, swe’;

Is there a Php function to convert this into an array so
that then $var_array is an array which contains: (‘usa’, ‘can’, ‘aus’, ‘swe’);

so that I can then do: if (in_array(‘usa’, $var_array)) {echo ‘selected’;}


explode() is what your looking for


Thanks the explode works fine.

No problem