Try all records

This commit is contained in:
Jannis Portmann 2022-01-17 17:11:17 +01:00
parent 9dbf0c72a1
commit 7a3749c105

View file

@ -11,8 +11,7 @@ class PlzToCoordinate
$content = file_get_contents("https://swisspost.opendatasoft.com/api/records/1.0/search/?dataset=plz_verzeichnis_v2&q=postleitzahl%3D" . $plz); $content = file_get_contents("https://swisspost.opendatasoft.com/api/records/1.0/search/?dataset=plz_verzeichnis_v2&q=postleitzahl%3D" . $plz);
$result = json_decode($content); $result = json_decode($content);
for ($i=0; $i<2; $i++) for($i = 0; $i < count($result->records); $i++) {
{
try { try {
$lat = $result->records[$i]->fields->geo_point_2d[0]; $lat = $result->records[$i]->fields->geo_point_2d[0];
$long = $result->records[$i]->fields->geo_point_2d[1]; $long = $result->records[$i]->fields->geo_point_2d[1];