Re: Using PHP to remove certain number of bytes from file
| From: | Robert Cummings | Date: | Sun, 30 Dec 2007 19:14:41 +0000 |
| Subject: | Re: Using PHP to remove certain number of bytes from file | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-266376@lists.php.net to get a copy of this message | ||
On Sun, 2007-12-30 at 17:20 +0000, Scott Wilcox wrote:
> Is it possible with PHP to remove a certain number of bytes from a file,
> purely within PHP?
Yes. Why wouldn't it?
> If so, does someone have an example of doing this, removing the first
> 230 bytes from a file.
No, that's an awfully specific problem. But here's the tools you'll
need:
fopen(), fread(), fwrite(), fclose().
Further info... you could do this without creating a separate temporary
file (meaning shift bytes within a single file), but I suggest using a
temporary target file for writing the new content, and then replacing
the original once everything has completed successfully.
Cheers,
Rob.
--
...........................................................
SwarmBuy.com - http://www.swarmbuy.com
Leveraging the buying power of the masses!
...........................................................