\n" ; $add = fopen($file, 'a' ); // Add $line to the file fwrite($add, $line); } else { // GET THE VALUE OF THE TAG. // Search the file for the value corresponding to the requested tag. $add = fopen($file, 'r' ); $exists = "" ; while(!feof($add)){ $line = fgets($add); $fields = explode(":", $line); if ($fields[0] == $tag) { $value = $fields[1]; $exists = "yes" ; } } // Send the result. if ($exists == "yes" ){ // Send the obtained value. $result = array( "VALUE" , $tag, $value); } else { // Send "not_found" that tag. $result = array( "VALUE" , $tag, "not_found" ); } $jsonResult = json_encode($result); echo $jsonResult; } fclose($add); ?>