Php - convert string to array -
i have array in string :
"[14,16,18]"
i want remove double quotation , result :
[14,16,18]
i've tried :
$restaurantids =request::all(); dd(trim(array_values($restaurantids)[0], '"'),array_values($restaurantids)[0] , $restaurantids) ;
and result :
"[14,16,18]" "[14,16,18]" array:1 [ "restaurant" => "[14,16,18]" ]
any suggestion?
you can below:-
<?php $string = "[14,16,18]"; $array = json_decode($string, true); print_r($array);
output:- https://eval.in/847737
another solution:-
<?php $string = "[14,16,18]"; $array = explode(',',str_replace(array('[',']'),array('',''),$string)); print_r($array);
output:-https://eval.in/847734
Comments
Post a Comment