php - Convert a real string that looks like an array into a proper array -


i have string of $data_regions when

echo $data_regions 

returns

["1","7"] 

so not proper array string mimicking array. need convert proper array of items need use command of

echo print_r($data_regions)  

which return

array ( [0] => 1 [1] => 7 ) 

i have tried spr_split no breaks down each individual character.

i suspect need preg_replace.. run through entire string , grab in " , add new array.

what have in string json. php has function json_decode directly change string array:

$array = json_decode($data_regions); 

Comments

Popular posts from this blog

neo4j - finding mutual friends in a cypher statement starting with three or more persons -

php - How to remove letter in front of the word laravel -

minify - Minimizing css files -