-1

How do I get the value of the key "exists" from the json response? I have previously tried

$json['data']['exists']
and 
$json['data']->exists

but it's not working. If I print_r the response this is what is being printed:

Array ( [exists] => )

My Current code:

<?php

    //Initialize cURL.
    $ch = curl_init();

    //Set the URL that you want to GET by using the CURLOPT_URL option.
    curl_setopt($ch, CURLOPT_URL, 'url');

    //Set CURLOPT_RETURNTRANSFER so that the content is returned as a variable.
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

    //Execute the request.
    $data = curl_exec($ch);

    $jsonData = json_decode($data,true);

    print_r($jsonData['data']);

    //Close the cURL handle.
    curl_close($ch);

?>
PixelBoii
  • 21
  • 2
  • 6

1 Answers1

0

It’s because the « exist » value is false. This is the reason why you’ve got an empty value in $jsonData[‘data’][‘exist’].

You will never see on printing a Boolean value ! It’s 1 for true and empty for false.

You can send false value as a string : ´false’