Bug #12332: Reading and Writing files
| From: | fred at surleau dot com | Date: | Tue, 24 Jul 2001 09:55:57 +0000 |
| Subject: | Bug #12332: Reading and Writing files | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-60839@lists.php.net to get a copy of this message | ||
From: fred@surleau.com
Operating system: All
PHP version: 4.0.6
PHP Bug Type: Feature/Change Request
Bug description: Reading and Writing files
Hi,
There is no fonction in PHP to read or write an integer or a long value
from a file.
Actually, I read a 2 or 4 characters string, and convert it into the
corresponding numeric value with this function :
function readNum( $f, $len )
{
$tmp = strrev( fread( $f, $len ) );
$val = 0;
for( $i=0; $i<$len; $i++ )
$val += ord(substr($tmp,$i,1)) * pow(256,$len-1-$i);
return $val;
}
Regards,
Fred.
--
Edit bug report at: http://bugs.php.net/?id=12332&edit=1