-3

I am getting below response from curl.

$response = curl_exec($ch);
    
echo $response;

{"notification":[{"text":"message 1","level":"one"}]}

I want to print "message 1"

Thanks in advance

Rohit Batham
  • 1,238
  • 1
  • 9
  • 13
  • 1
    [`json_decode()`](https://www.php.net/manual/function.json-decode.php) may help – Cid May 10 '21 at 08:16
  • @Cid, Thank you. It works!!! – Rohit Batham May 10 '21 at 08:19
  • 2
    https://www.php.net/manual/en/language.types.object.php has a manual on objects (and how to access attributes). If you don't want to use objects you can use `true` as the second parameter for `json_decode()` to get the results as array. – brombeer May 10 '21 at 08:22

1 Answers1

-1

I think you can do it like this:

echo $response["notification"]["text"]; 
Matteo
  • 118
  • 2
  • 12