0

So i have a curl that returns this response.

 {"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"}}]}

How ever I only want to echo (tokencc_bc_pyp7yn_vgdr5x_rr6rj8_zntbj5_n45) to be clean

I have already tried this code but it doesnt work

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";

1 Answers1

0

$message will be json, so you'll need to first use json_decode on the result.

Then in order to access 'message' you would do this just as you would any other object.

$message = json_decode($message);
echo $message->message;
Mark
  • 1,852
  • 3
  • 18
  • 31