Parsing Json Array in PHP with keys -


i wanted parse data array given path ($path), each 1 key in json array.

$data['system']['local']['version'] = 1; $path = "system.local.version";  $key_array = explode(".", $path);   foreach ( $key_array $keys) {     if( !array_key_exists($keys,$data)) {         return -1;     }      $data = $data[$keys]; }  print_r($data); 

ps : need complete path after traversing json array givenn path (keys).

ex : - want after traversing array ( expected output above code).

array (     [system] => array         (             [local] => array                 (                     [version] => 1                 )         ) ) 


Comments

Popular posts from this blog

python - No exponential form of the z-axis in matplotlib-3D-plots -

php - Best Light server (Linux + Web server + Database) for Raspberry Pi -

c# - "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" error when deserializing class -