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
Post a Comment