I tried transfer $str to be an array group.
$str = '1,2,3,4,5';
print_r(array($str)); //this get Array ( [0] => 1,2,3,4,5 )
I tried compact
print_r(array(compact($str))); // Array ( [0] => Array ( ) )
but how to make $str to be
Array
(
[0] => 1
[1] => 2
[2] => 3
[3] => 4
[4] => 5
)
Try with:
Otherwise, if you mean that your input is ‘1,2,3,4,5’ then use explode:
In both cases the output of print_r($str); is: