From 8b1a766791a1da60117a8303e3103a54128784a5 Mon Sep 17 00:00:00 2001 From: Terry Date: Mon, 5 Nov 2018 13:13:48 +0100 Subject: [PATCH] check if array key exists, fixes undefined offset: 0 error --- src/Cornford/Googlmapper/Mapper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Cornford/Googlmapper/Mapper.php b/src/Cornford/Googlmapper/Mapper.php index b768729..7f4ade2 100644 --- a/src/Cornford/Googlmapper/Mapper.php +++ b/src/Cornford/Googlmapper/Mapper.php @@ -176,7 +176,7 @@ public function location($location) $postalCode = null; foreach ($resultObject->results[0]->address_components as $addressComponent) { - if ($addressComponent->types[0] == 'postal_code') { + if (count($addressComponent->types) > 0 && $addressComponent->types[0] == 'postal_code') { $postalCode = $addressComponent->long_name; } }