如何在php中将64位无符号整数转换为十六进制值?

如何在php中将64位无符号整数转换为十六进制值?,php,integer,64-bit,Php,Integer,64 Bit,我通过API将事件发布为64位无符号整数,并需要使用php将其转换为十六进制值,以识别发生的所有事件 我收到的一些事件/整数示例如下所示; 80001000000或 80010000000或 800亿 我要查找的输出/十六进制值在此图像(裁剪图像)中进行了说明: 如果有人需要解决此问题: <?php class Decoder { public static function decode($event) { $decimal = hexdec("$e

我通过API将事件发布为64位无符号整数,并需要使用php将其转换为十六进制值,以识别发生的所有事件

我收到的一些事件/整数示例如下所示; 80001000000或 80010000000或 800亿

我要查找的输出/十六进制值在此图像(裁剪图像)中进行了说明:


如果有人需要解决此问题:

<?php

class Decoder {

    public static function decode($event) {
        $decimal = hexdec("$event");
        $binary = decbin("$decimal");
        $split_binary = str_split($binary);
        $binary_length = strlen($binary) - 1;

        $indicators = array();
        $index = 0;
        foreach ($split_binary as $letter) {
            if ($letter == '1')
            {
                $signal = $binary_length - $index;
                array_push($indicators, $signal);
            }
            $index ++;
        }

        return $indicators;
    }
}

$events = array('40010000000', '40002000000', '80000000000');

foreach ($events as $event) {
    print_r(Decoder::decode($event));
}

?>

归功于软件开发人员