{"id":12063,"date":"2022-03-15T18:40:22","date_gmt":"2022-03-15T22:40:22","guid":{"rendered":"http:\/\/local.brightwhiz\/?post_type=snippets&p=12063"},"modified":"2022-03-15T18:40:24","modified_gmt":"2022-03-15T22:40:24","slug":"php-parse-json-code","status":"publish","type":"snippets","link":"http:\/\/local.brightwhiz\/snippets\/php-parse-json-code\/","title":{"rendered":"PHP Parse JSON Code"},"content":{"rendered":"\n
PHP parse JSON code example.<\/p>\n\n\n\n
$json = '{ "name":"John Denver", "title":"Marketing Director" }';\n\n$person = json_decode( $json );\n\necho $person->name; \/\/ John Denver\n\necho $person->title; \/\/ Marketing Director\n\n\/\/ use this to returned an associative array:\n\n$data = json_decode( $json, true );\n\necho $data["name"]; \/\/ John Denver\n\necho $data["title"]; \/\/ Marketing Director\n\nPHP decode JSON file.\n\n$json = json_decode( file_get_contents( '\/path\/to\/your\/file.json' ) );<\/code><\/pre>\n","protected":false},"comment_status":"open","ping_status":"closed","template":"","meta":[],"categories":[953,25,27,15,16,18],"tags":[328,334,350,424,433,452,544,591,635,638],"yoast_head":"\nPHP Parse JSON Code [Snippet]<\/title>\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\t\n