inTime = gmdate('H:i:s',time()); //Adds a new property to the object we get after decoding the json and stores the current time. $encoded_location = json_encode($decoded_location); //Reencodes the object back into a json with the new inTime property. $file = 'db.txt'; $totalLines = intval(exec("wc -l '$file'")); //Counts how many lines db.txt has. //echo $totalLines. "\n"; //For testing purposes if($totalLines > 15) //If db.txt has more than a specified amount of lines, it will delete the first line of db.txt. { read_and_delete_first_line("db.txt"); } $db = fopen("db.txt","a") or die("FAILED TO ACCESS DATABASE"); //Opens db.txt in append mode. If it somehow fails to open the database, an error message will be displayed. fwrite($db,$encoded_location. "\n"); //Writes the newly encoded json into db.txt. fclose($db); //Closes db.txt //$totalLines = intval(exec("wc -l '$file'")); //For testing purposes //echo $totalLines; //For testing purposes ?>