Page 1 of 1

PHP Notice: Undefined offset: 11 in get-metar-conditions-inc.php

Posted: Mon 05 Mar 2018 8:27 am
by ConligWX
Ken

just had this notice in apache logs when visiting the wxmetar.php on my site:

Code: Select all

[Sun Mar 04 23:54:31.517313 2018] [php7:notice] [pid 21322:tid 140681158805248] [client xx.xxx.xx.6:49533] PHP Notice:  Undefined offset: 11 in /htdocs/weather/get-metar-conditions-inc.php on line 752
when i looked at the line 752 it shows:

Code: Select all

      $part = $metarParts[$metarPtr];
Any help in this would be most greatful.

I'm thinking it maybe something to do with the data coming back from the airports perhaps?

Re: PHP Notice: Undefined offset: 11 in get-metar-conditions-inc.php

Posted: Wed 07 Mar 2018 10:55 am
by tmabell
Try changing

$part = $metarParts[$metarPtr];

to this:

$part = $metarParts['$metarPtr'];

Re: PHP Notice: Undefined offset: 11 in get-metar-conditions-inc.php

Posted: Wed 07 Mar 2018 1:19 pm
by ConligWX
Thanks I'll give it a go, I've not had the error since, but no doubt it will crop up again soon. I'll make the changes and check the logs again in a few days time.

Re: PHP Notice: Undefined offset: 11 in get-metar-conditions-inc.php

Posted: Wed 07 Mar 2018 2:29 pm
by ConligWX
I tried that, but all the data disappears.
meter_test.JPG
Thanks for the suggestion however even when the error appears in the apache log, the end result on the wxmetar.php page is fine so its not that bad an issue.