I want to read file without last x bytes in php, exactly like this:
$size = filesize($filename) - $x;
$handle = fopen($filename, "rb");
$contents = fread($handle, $size);
fclose($handle);
In my application, I will use this code a lot.
This works, but is it possible to do this more briefly and flexible, instead of using (filesize, fopen, fclose) each time?
Can file_get_contents() help? If so how do I use it?
For example (the very simple solution)
Just remove the last bytes/characters.