ID: 12332
Updated by: mfischer
Reported By: [EMAIL PROTECTED]
Old Status: Open
Status: Closed
Bug Type: Feature/Change Request
Operating System: All
PHP Version: 4.0.6
New Comment:

You actually use pack() and unpack() to prepare binary data to be written or to be 
read, see their manual entries.

Previous Comments:
------------------------------------------------------------------------

[2001-07-24 05:55:57] [EMAIL PROTECTED]

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 this bug report at http://bugs.php.net/?id=12332&edit=1


-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to