在这个代码片段我想将我的值转换为ascii(注释),我使用ord函数,我不知道它是否正确然后我想将它转换为字节,我的问题是我怎么能这样做?
$time=time();
$timeStamp = date("Ymdhis",$time).'<br>';
$serviceID = '98012000018449';
$price = '3000';
$cpCode = '';
$requestID = rand(1,100);
$key = $serviceID + $serviceID + $price + $timeStamp + $requestID;
$encodedKey = ord($key);//here i want convert to asccii
答案 0 :(得分:0)
您可以使用unpack()
print_r(unpack("C*", $key));
这将为您提供与ord()
相同的输出Array
(
[1] => 50
[2] => 49
[3] => 54
[4] => 49
[5] => 57
[6] => 53
[7] => 48
[8] => 50
[9] => 50
[10] => 49
[11] => 48
[12] => 51
[13] => 55
[14] => 55
[15] => 48
)
在这个答案中你可以找到更多信息