Alternatively, assuming they all have same rigid structure, ...
$fp = file('weather.html', FILE_IGNORE_NEW_LINES|FILE_SKIP_EMPTY_LINES);
$data = [];
foreach ($fp as $line) {
switch (substr($line, 0, 4)) {
case '<!--' :
if ($line[4]!=' ') {
$section = substr($line, 4, -8);
}
break;
case '<td>' :
list($name, $value) = getData($line);
$data[$section][$name] = $value;
break;
default :
continue 2;
}
}
function getData($line) {
$l = substr($line, 4, -5);
return explode('</td><td>', $l);
}
// View the results
echo '<pre>' . print_r($data, 1) . '</pre>';
giving ...
$data = Array
(
[MISCELLANEOUS] => Array
(
[Name of Station] => AzureCove
[City (from NOAA Setup)] => Garden City
[State (from NOAA Setup)] => Utah
[Elevation (from NOAA Setup)] => 5954 ft
[Latitude (from NOAA Setup)] => 41° 56' 12" N
[Longitude (from NOAA Setup)] => 111° 23' 20" W
[Date on the PC] => 03/13/23
[Time on the PC] => 4:06a
[UTC Time] => 10:06a
[UTC Date] => 03/13/23
[Date on the Station] => 03/13/23
[Time on the Station] => 4:05a
[Sunrise Time] => 7:41a
[Sunset Time] => 7:30p
[Current Weather Forecast *] => Partly cloudy with little temperature change.
[Current Moon Phase] => Last Quarter
[EMC] => ---
[EMC Unit] => %
[Air Density] => 0.0842
[Air Density Unit] => lb/cu.ft
)
[INSIDE TEMPERATURE] => Array
(
[Inside Temperature] => 42.5
[High Inside Temperature] => 43.6
[Time of High Inside Temperature] => 12:00a
[Low Inside Temperature] => 42.5
[Time of Low Inside Temperature] => 3:41a
[High Monthly Inside Temperature] => 45.4
[Low Monthly Inside Temperature] => 39.4
[High Yearly Inside Temperature] => 45.7
[Low Yearly Inside Temperature] => 39.4
)
[OUTSIDE TEMPERATURE] => Array
(
[Outside Temperature] => 15.1
[High Outside Temperature] => 21.7
[Low Outside Temperature] => 15.1
[Time of High Outside Temperature] => 12:00a
[Time of Low Outside Temperature] => 4:04a
[High monthly Outside Temperature] => 46.1
[Low monthly Outside Temperature] => -11.3
[High yearly Outside Temperature] => 46.1
[Low yearly Outside Temperature] => -12.5
)
.
.
.
)