protected function addBinary($left, $right) {
        $len    = max(strlen($left), strlen($right));
        $left   = str_pad($left, $len, chr(0), STR_PAD_LEFT);
        $right  = str_pad($right, $len, chr(0), STR_PAD_LEFT);
        $result = '';
        $carry  = 0;
        for ($i = 0; $i < $len; $i++) {
            $sum     = ord($left[$len - $i - 1])
                 + ord($right[$len - $i - 1])
                 + $carry;
            $result .= chr($sum % 256);
            $carry   = $sum >> 8;
        }
        while ($carry) {
            $result .= chr($carry % 256);
            $carry >>= 8;
        }
        return strrev($result);
    }
protected function addBinary($left, $right) {
        $len    = max(strlen($left), strlen($right));
        $left   = str_pad($left, $len, chr(0), STR_PAD_LEFT);
        $right  = str_pad($right, $len, chr(0), STR_PAD_LEFT);
        $result = '';
        $carry  = 0;
        for ($i = 0; $i < $len; $i++) {
            $sum     = ord($left[$len - $i - 1])
                 + ord($right[$len - $i - 1])
                 + $carry;
            $result .= chr($sum % 256);
            $carry   = $sum >> 8;
        }
        while ($carry) {
            $result .= chr($carry % 256);
            $carry >>= 8;
        }
        return strrev($result);
    }
protected function addBinary ( $ left , $ right ) { $ len = max ( strlen ( $ left ) , strlen ( $ right ) ) ; $ left = str_pad ( $ left , $ len , chr ( 0 ) , STR_PAD_LEFT ) ; $ right = str_pad ( $ right , $ len , chr ( 0 ) , STR_PAD_LEFT ) ; $ result = '' ; $ carry = 0 ; for ( $ i = 0 ; $ i < $ len ; $ i ++ ) { $ sum = ord ( $ left [ $ len - $ i - 1 ] ) + ord ( $ right [ $ len - $ i - 1 ] ) + $ carry ; $ result .= chr ( $ sum % 256 ) ; $ carry = $ sum >> 8 ; } while ( $ carry ) { $ result .= chr ( $ carry % 256 ) ; $ carry >>= 8 ; } return strrev ( $ result ) ; }
Add two binary strings together

@param string $left  The left argument
@param string $right The right argument

@return string The binary result
Add two binary strings together