所以我有一个卷发,会返回此响应。
{"creditCards":[{"type":"CreditCard","nonce":"tokencc_bd_v3vyfk_7r75rw_vcprsv_yds997_9gz","description":"ending in 00","consumed":false,"threeDSecureInfo":null,"details":{"bin":"434769","lastTwo":"00","lastFour":"1100","cardType":"Unknown"},"binData":{"prepaid":"No","healthcare":"Unknown","debit":"Yes","durbinRegulated":"Unknown","commercial":"Unknown","payroll":"Unknown","issuingBank":"Unknown","countryOfIssuance":"USA","productId":"Unknown"}}]}
但是我只想回声(tokencc_bc_pyp7yn_vgdr5x_rr6rj8_zntbj5_n45)干净
我已经尝试过此代码,但无法正常工作
function GetStr($string, $start, $end)
{
$str = explode($start, $string);
$str = explode($end, $str[1]);
return $str[0];
}
$message = trim(strip_tags(getstr($curl,'nonce": "','"')));
echo"$message";
答案 0 :(得分:0)
$ message将为json,因此您首先需要在结果上使用json_decode。
然后,为了访问“消息”,您将像处理任何其他对象一样执行此操作。
$message = json_decode($message);
echo $message->message;