php 十六进制累加校验码

生成十六进制累加校验码

function getcheckcode($data){
    if($data){
		$arr = array();
		$arr = str_split($data, 2);
		$result = 0;
		for ($i=0; $i < count($arr); $i++) {
			$result =$result + hexdec($arr[$i]);
		}
        $result = strtoupper('0'.dechex($result)); //转换成大写
        return $result;
	}
}

如果有什么问题及不懂的可以于关注公众号 回复999加我微信交流下 

 

Guess you like

Origin blog.csdn.net/loveyoulouyou/article/details/120314021
php