lib/danog/PHP/StructTools.php
public function num_unpack($s, $blocksize, $unsigned)
    {
        $length = strlen($s);
        $bitnumber = $blocksize * 8;
        if ($length != $blocksize) {
            trigger_error('Given data length ('.$length.') is different from the required length ('.$blocksize.').');
        }
        $bits = '';
        foreach (str_split($s) as $i) {
            $bits .= $this->decbin(ord($i), 8);
        }

        return $this->bindec($bits, $unsigned);
    }
public function num_unpack($s, $blocksize, $unsigned)
    {
        $length = strlen($s);
        $bitnumber = $blocksize * 8;
        if ($length != $blocksize) {
            trigger_error('Given data length ('.$length.') is different from the required length ('.$blocksize.').');
        }
        $bits = '';
        foreach (str_split($s) as $i) {
            $bits .= $this->decbin(ord($i), 8);
        }

        return $this->bindec($bits, $unsigned);
    }
num_unpack.

Convert a byte string to an integer.
This is (essentially) the inverse of num_pack().

@param	$s		    Data to unpack
@param	$blocksize	Block size
@param   $unsigned Boolean that determines whether to work in signed or unsigned mode

@return float or int with the unpack value