If you need to insert a comma separated string into a variable you can accomplish this with the following code.
Let’s take a look at our string.
$myString = "3,8,18,22";
We can insert our string into an array by simply using the explode() function.
$newString = explode(',', $myString);
Now if we use the print_r() function we can view our array.
print_r($newString);
We should now see the following.
Array ( [0] => 3,8,18,22 )
Enjoy!!