function set_metrics_data($data_list) { if (is_file_writing_working()) { $file_name = __PATH_METRICS__ . 'metrics_data.json'; // Ensure the list is sorted by their timestamps before being stored. usort($data_list, function ($a, $b) { return strcmp($a['timestamp'], $b['timestamp']); }); //var_dump($data_list); $str_json = json_encode($data_list); file_put_contents($file_name, $str_json); } else { throw new Exception('ERROR FILE WRITING IS NOT WORKING.'); } }
function set_player_data($group, $player_data) { if (is_file_writing_working()) { $player_data_file_name = __PATH_PLAYER_DATA__ . 'player_data_' . $group . '.json'; $str_json = json_encode($player_data); file_put_contents($player_data_file_name, $str_json); } else { throw new Exception('ERROR FILE WRITING IS NOT WORKING.'); } }