note 79020 added to function.unpack
| From: | phpclub at rambler dot ru | Date: | Wed, 07 Nov 2007 12:28:10 +0000 |
| Subject: | note 79020 added to function.unpack | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-132076@lists.php.net to get a copy of this message | ||
Correct substr
If you are trying to make unpack 'N' work with unsigned long on 64 bit machines, you
should take a look to this bug:
http://bugs.php.net/bug.php?id=40543
An ugly workaround for me was:
//Read a 4-byte integer from file
$_r = fread($f,4);
$a=unpack('Ni',$_r);
$b = sprintf("%b", $a['i']); // binary representation
if(strlen($b) == 64){
$new = substr($b, 32);
$a['i'] = bindec($new);
}
----
Server IP: 195.54.192.44
Probable Submitter: 91.149.66.60
----
Manual Page -- http://www.php.net/manual/en/function.unpack.php
Edit -- https://master.php.net/note/edit/79020
Del: integrated -- https://master.php.net/note/delete/79020/integrated
Del: useless -- https://master.php.net/note/delete/79020/useless
Del: bad code -- https://master.php.net/note/delete/79020/bad+code
Del: spam -- https://master.php.net/note/delete/79020/spam
Del: non-english -- https://master.php.net/note/delete/79020/non-english
Del: in docs -- https://master.php.net/note/delete/79020/in+docs
Del: other reasons-- https://master.php.net/note/delete/79020
Reject -- https://master.php.net/note/reject/79020
Search -- https://master.php.net/manage/user-notes.php