TCPDFBarcode::dec_to_hex PHP Method

dec_to_hex() public method

(requires PHP bcmath extension).
public dec_to_hex ( $number ) : string
$number (string) number to convert specified as a string
return string hexadecimal representation
    public function dec_to_hex($number)
    {
        $i = 0;
        $hex = array();
        if ($number == 0) {
            return '00';
        }
        while ($number > 0) {
            if ($number == 0) {
                array_push($hex, '0');
            } else {
                array_push($hex, strtoupper(dechex(bcmod($number, '16'))));
                $number = bcdiv($number, '16', 0);
            }
        }
        $hex = array_reverse($hex);
        return implode($hex);
    }