<?php
/**
* function to read a json file and display all the data on the json with comments
* @param string $file_name Name of the json file
* @return $data
*/
function readJsonFile($file_name) {
// read the json file
$data = file_get_contents($file_name);
// decode the json data into an associative array
$data = json_decode($data, true);
// return the data
return $data;
}
//example
$result = readJsonFile('data.json');
//output
echo $result; //{"name":"John","age":30,"city":"New York"}
For further actions, you may consider blocking this person and/or reporting abuse
Top comments (0)