Convert String with square brackets to PHP Array -



Convert String with square brackets to PHP Array -

i have string, values in brackets , separated comma, array string

example [[["name" , "id"] , [12]] , ["test" , 78] , 0]

how convert string php array?

json string utilize json_decode():

$array = json_decode($string); print_r($array); array ( [0] => array ( [0] => array ( [0] => name [1] => id ) [1] => array ( [0] => 12 ) ) [1] => array ( [0] => test [1] => 78 ) [2] => 0 )

just fyi, works well:

eval('$array = ' . $string . ';'); print_r($array);

php

Comments

Popular posts from this blog

model view controller - MVC Rails Planning -

ruby on rails - Devise Logout Error in RoR -

html - Submenu setup with jquery and effect 'fold' -