I make an API call and try to convert the json Response to a php Array. However when checking with the is_array function, it turns out it isn't an Array.
Call to Api
$ch = curl_init("https://api.url.com/value/value");
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json' , "token"));
$result = curl_exec($ch);
curl_close($ch);
$result = json_decode($result);
Json the API call Returns:
[
{
"number":"65",
"Field":"test",
"Name":"test",
"type":"Numeric",
"MaximumLength":128,
"MinimumLength":0,
"Options":"required"
}
]
and so on.
I decode it using
json_decode($result);
However, checking like this
if (is_array($result)) {
echo "is array";
} else {
echo "is not an array!";
}
echoes "is not an Array".
I checked the json Response and it's valid json code. I also tried
json_decode($result, true);
with the same result.
Am I making some obvious mistake?