Re: Fwd: [PHP] Using PHP to remove certain number of bytes from file
- From: heavyccasey@xxxxxxxxx (Casey)
- Date: Sun, 30 Dec 2007 11:44:21 -0800
On Dec 30, 2007 11:26 AM, Robert Cummings <robert@xxxxxxxxxxxxx> wrote:
On Sun, 2007-12-30 at 14:14 -0500, Benjamin Darwin wrote:30 seconds alternative:
Maybe one of these days I'll remember to actually reply to the list the
first time.
---------- Forwarded message ----------
From: Benjamin Darwin <bddarwin@xxxxxxxxx>
Date: Dec 30, 2007 2:12 PM
Subject: Re: [PHP] Using PHP to remove certain number of bytes from file
To: Scott Wilcox <sc0tt@xxxxxxx>
Try this:
$file_data = file_get_contents('filename', false, null, 230);
file_put_contents('filename', $file_data);
I don't suggest this route with files that are in the hundreds of
megs :) But admittedly, it's the simplest solution for small files.
Also, can't use it if you're stuck with PHP 4 since it doesn't support
file_put_contents(). PHP4 is dead now anyways, supposedly, so I read
someplace ;)
Cheers,
Rob.
--
...........................................................
SwarmBuy.com - http://www.swarmbuy.com
Leveraging the buying power of the masses!
...........................................................
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
<?php
$fh = fopen($file, 'rb');
$f2 = fopen('temp', 'wb');
fseek($fh, 230);
do {
fwrite($f2, fread($fh, 4069));
} while (!feof($fh);
fclose($fh);
fclose($f2);
rename('temp', $file);
?>
-Casey
.
- References:
- [PHP] Comparison Problems with 5.2.5
- From: Magnus Anderson
- Re: [PHP] Comparison Problems with 5.2.5
- From: Silvio Porcellana
- Using PHP to remove certain number of bytes from file
- From: Scott Wilcox
- Fwd: [PHP] Using PHP to remove certain number of bytes from file
- From: "Benjamin Darwin"
- Re: Fwd: [PHP] Using PHP to remove certain number of bytes from file
- From: Robert Cummings
- [PHP] Comparison Problems with 5.2.5
- Prev by Date: Re: [PHP] Question about sqli class
- Next by Date: read email
- Previous by thread: Re: Fwd: [PHP] Using PHP to remove certain number of bytes from file
- Next by thread: Re: [PHP] Using PHP to remove certain number of bytes from file
- Index(es):