Handle Response Curl with PHP

Asked

Viewed 287 times

0

I am integrating an email service with Curl and PHP and would like to pick up the answer that comes in this format:

{
  "id": 8
}

How do I get the field number ID with PHP?

  • Gives a "var_dump()" in the returned value and checks whether it is an object or an array. If it is array, you will use $return["id"], if it is object, you will use $return->id

1 answer

1


As you did not put your code, I will briefly illustrate here a possible solution

$response = curl_exec($ch);
$retorno = json_decode($response, true)
echo $response["id"];
  • Thanks, just as soon as you solved!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.