|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2001-07-24 09:59 UTC] mfischer@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Nov 05 10:00:02 2025 UTC |
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.