Thanks so much
Wim! That script looks very similar to the one I created last night. I think I messed up my previously working script while making changes and planned on restoring the old version from TimeMachine today and double-checking the steps. But your file includes the ability to catch and display errors which I failed to include in the originals... my bad, I know.
Just ran your script and it worked perfectly... of course!
Next I'll try mine... Working again!
Naturally, the process took longer than needed because of my lack of skills... Also learned the difference between $rawData = curl_exec ($ch) and $info = curl_getinfo($ch);
Thanks for explaining how to get and display errors, also!
I plan on putting all but one of the CURLOPT settings in an array. Mainly to make the main code block more compact. I run that block in a loop for the five airports I want. That means I need to change the curl_setopt($curl, CURLOPT_URL, $raw_METAR[$airport]); as a separate option inside the loop. All the others will be set with a curl_setopt_array($curl, $options );
Previously, I was closing the connection after the loop ended. I will look up the specifications and do some searching as to whether which method is best:
- open/collect data/close in a loop
- open once/collect data five times/close when finished
It probably makes no speed difference, but one way may be preferred by servers/professionals.
DoinitMyWay! Thanks to the expert help of Mr. van der Kuil!