public static function bitmap2bytes($bitmap, $checkLen = 0)
    {
        $r = '';
        $bitmap = str_pad($bitmap, ceil(strlen($bitmap) / 8) * 8, '0', STR_PAD_LEFT);

        for ($i = 0, $n = strlen($bitmap) / 8; $i < $n; ++$i)
        {
            $r .= chr((int) bindec(static::binarySubstr($bitmap, $i * 8, 8)));
        }
        if ($checkLen && (strlen($r) != $checkLen)) {
            throw new Exception('Warning! Bitmap incorrect.');
        }

        return $r;
    }
public static function bitmap2bytes($bitmap, $checkLen = 0)
    {
        $r = '';
        $bitmap = str_pad($bitmap, ceil(strlen($bitmap) / 8) * 8, '0', STR_PAD_LEFT);

        for ($i = 0, $n = strlen($bitmap) / 8; $i < $n; ++$i)
        {
            $r .= chr((int) bindec(static::binarySubstr($bitmap, $i * 8, 8)));
        }
        if ($checkLen && (strlen($r) != $checkLen)) {
            throw new Exception('Warning! Bitmap incorrect.');
        }

        return $r;
    }
public static function bitmap2bytes ( $ bitmap , $ checkLen = 0 ) { $ r = '' ; $ bitmap = str_pad ( $ bitmap , ceil ( strlen ( $ bitmap ) / 8 ) * 8 , '0' , STR_PAD_LEFT ) ; for ( $ i = 0 , $ n = strlen ( $ bitmap ) / 8 ; $ i < $ n ; ++ $ i ) { $ r .= chr ( ( int ) bindec ( static :: binarySubstr ( $ bitmap , $ i * 8 , 8 ) ) ) ; } if ( $ checkLen && ( strlen ( $ r ) != $ checkLen ) ) { throw new Exception ( 'Warning! Bitmap incorrect.' ) ; } return $ r ; }
Convert bitmap into bytes.

@param string $bitmap
@param int $checkLen
@return string
@throws Exception
Convert bitmap into bytes .