This may sound DUPLICATE, but I tried all the answers with this same question.
I am using this API, https://smartystreets.com/docs/cloud/us-street-api
My problem is, the output of their INVALID ADDRESS is
[ ]
It is also stated in their documentation.
Now, this is my code but it's not working.
$url = 'SOME_API_HERE' ;
$url = str_replace(" ", '%20', $url);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch);
curl_close($ch);
$json = json_decode($result, true);
if (!empty($json))
{
return json_decode($result, true);
}
else {
return 'invalid address';
}