It's a simple PHP script with no framework of any kind. I get a very large (15MB, I have no choice but deal with it) local json file and use it for different operations.
Right now I use the global
keyword to call it from functions but it doesn't feel very good. I also wonder about performances. Is there a more proper simple way to do for this kind of purpose ?
$data = json_decode(file_get_contents("data.json"), true);
function randomItem() {
global $data;
return array_rand($data);
}
$item = randomItem();
var_dump($data[$item]);