I have this variable $csv = '3,6,7,8';
that i need to convert to a square bracketed array of the form $csv_array = [3,6,7,8];
If i explode the csv like $new_array=explode(",",$csv);
,it does not give me the array i want.
This is a running example http://3v4l.org/kYC0g
The code
$csv = '3,6,7,8';
$new_csv = '['.$csv.']';
if(is_array($new_csv)){
echo 'true';
}
else{
echo 'false';
//this is false
}
echo '<br/>';
$new_array=explode(",",$csv);
print_r($new_array);
//not what i am looking for
echo '<br/>';
print_r($new_csv);
echo '<br/>';
echo $new_csv;