note 19499 modified in function.bindec by vrana
| From: | vrana@php.net | Date: | Tue, 17 Aug 2004 14:52:58 +0000 |
| Subject: | note 19499 modified in function.bindec by vrana | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-79718@lists.php.net to get a copy of this message | ||
For converting larger-than-31-bit numbers:
<?php
function Bin2Dec($binstring) {
for ($i=0;$i<strlen($binstring);$i++) {
$decvalue += ((int) substr($binstring, strlen($binstring) - $i - 1, 1)) * pow(2, $i);
}
return $decvalue;
}
?>
--was--
For converting larger-than-31-bit numbers:
function Bin2Dec($binstring) {
for ($i=0;$i<strlen($binstring);$i++) {
$decvalue += ((int) substr($binstring, strlen($binstring) - $i - 1, 1)) * pow(2, $i);
}
return $decvalue;
}
http://php.net/manual/en/function.bindec.php