Is it possible to overwrite a certain part of a txt file in php?

Let's say we have a .txt file with the text "1234567890", is it possible to change the 1 to a 9 so it says "9234567890" without touching the remaining numbers?

To clarify, it should only change a part of the text file and not rewrite the entire thing. I'm only allowed to use php and html.


This can be a one-liner, but I'm breaking it up so it makes more sense. Further, this would be faster using exec with sed or awk, but this is just PHP here.

$string = file_get_contents("yourfile");
$string = str_replace('1','9',$string);
file_put_contents("youfile", $string);

Need Your Help

Creating a GUI like interface using html

html css layout

I am trying to create a resizable html page that mimics the java applet clock layout and am not sure if I am approaching this in the right way. This 3 clock picture below is what I am trying to cr...