Overwrite or delete a specific line in an external text file

I need to change the last line of an external text file
The file consists of

Last Connection: 1/20/2008 1:44:08 PM
Indoor Temperature: 73
Outdoor Temperature: 21
Indoor Setpoint: 72
New Setpoint: 55

I need to know how to change the last line (replace it with a user input)

ok this is how i started it trying to separate lines and only change the last one and i’m very stuck

<?php $file_handle = fopen("filename.txt", "rb"); while (!feof($file_handle) ) { $line_of_text = fgets($file_handle); $parts = explode('=', $line_of_text); print $line_of_text. "
"; } fclose($file_handle); ?>

thank you

array_pop ($lines);
array_push ($lines,“new text”);

Sponsor our Newsletter | Privacy Policy | Terms of Service