How to split the data of the form ["1","2","3"]
and store in array as [1,2,3]
in PHP
?
I need this data in order to get or fetch data from a mysql
table which is having data as id 1 data red, id 2 data blue. so that i need the data to be converted to 1 2 3 so that I can give it in query to fetch the data.
Please someone help me thanks.
Something like this will do , Run this after your while
.
$int_arr = array_map('intval',$your_returned_array);
EDIT:
ok am sorry it is column value in table it is totally a string which i have to split as numbers
Do like this..
$str= '["1","2","3"]';
preg_match_all('/"(.*?)"/', $str, $matches);
print_r(array_map('intval',$matches[1]));
OUTPUT :
Array
(
[0] => 1
[1] => 2
[2] => 3
)