Lets begin with an example. Say in a file file.php following texts exist.
This is just to show example. This is just to show example. This is just to show example. This is just to show example. end. Okay This is just to show example. This is just to show example.
Now in the above text if i find okay then i will remove the rest of the content including the word okay and save the file in the server.
Someone please show me an efficient way to do this.
You could also use
explodeto split the content. Depending on how extensive your problem is this may not be the best solution, but I thought I would just include it also: