Try this
$fh = fopen($path, 'r+') or die("can't open file");$stat = fstat($fh);ftruncate($fh, $stat['size']-1);fclose($fh);
For more help see this