AWS-HMAC-SHA256 凭证= eyJhbGciOiJIUzI1NiIsIngtc3MiOjEy / 20160911 / cn / user-service / request,SignedHeaders = host; x-awsdate, 签名= d9ee2d43f2067e4b8857f15fa8fff27820051d95a4ec31e93be866f201e0797a
常规如何匹配凭据,SignedHeaders,签名?
答案 0 :(得分:0)
您可以使用explode和array_map代替正则表达式:
$str = "AWS-HMAC-SHA256 Credential=eyJhbGciOiJIUzI1NiIsIngtc3MiOjEy/20160911/cn/user-service/request,SignedHeaders=host;x-aws-date, Signature=d9ee2d43f2067e4b8857f15fa8fff27820051d95a4ec31e93be866f201e0797a";
$res = array_map(function($x){
return explode('=', $x)[1];
}, explode(',', $str));
print_r($res);
结果:
Array
(
[0] => eyJhbGciOiJIUzI1NiIsIngtc3MiOjEy/20160911/cn/user-service/request
[1] => host;x-aws-date
[2] => d9ee2d43f2067e4b8857f15fa8fff27820051d95a4ec31e93be866f201e0797a
)