为付款而启动的交易,并从恢复形成交易,并希望在页面上显示结果和保存到我的数据库
if (!($data = curl_exec($ch))) {
return ERROR;
}
curl_close($ch);
unset($ch);
print "\n$data\n";
$data = explode("&",$data);
for($i=0;$i<count($data);$i++) {
$rdata = explode("=",$data[$i]);
$this->responses[$rdata[0]] = $rdata[1];
}
return $this->responses['response'];
}
Result
response=1&responsetext=SUCCESS&authcode=123456&transactionid=2766128623&avsresponse=N&cvvresponse=M&orderid=1123400&type=sale&response_code=100
现在我想在页面上显示每个项目 响应= 1 响应文字=成功
答案 0 :(得分:1)
它被称为查询字符串。你可以做到
parse_str ('response=1&responsetext=SUCCESS&authcode=123456&transactionid=2766128623&avsresponse=N&cvvresponse=M&orderid=1123400&type=sale&response_code=100', $resp);
print_r($resp);
并给出结果数组
Array
(
[response] => 1
[responsetext] => SUCCESS
[authcode] => 123456
[transactionid] => 2766128623
[avsresponse] => N
[cvvresponse] => M
[orderid] => 1123400
[type] => sale
[response_code] => 100
)
或者不要说第二个参数,然后你会给名字作为数组键的变量
答案 1 :(得分:1)
通常如下 -
$data = "response=1&responsetext=SUCCESS&authcode=123456&transactionid=2766128623&avsresponse=N&cvvresponse=M&orderid=1123400&type=sale&response_code=100";
$data = explode("&",$data);
// use print_r if needed
//print_r($data);
foreach($data as $d) {
echo $d .'<br/>';
}
对于Key / Label,您必须执行一些pregmatch
技巧来实现类似 -
Response Text or Response or Auth Code
答案 2 :(得分:0)
您可以尝试str_replace()
替换'&amp;'使用'',您可以使用ucwords()
进行大写
ucwords(str_replace('&',$this->responses['response'];))