Hi all,
I have scrapped a webpage and now I have data I would like to rearrange. I am terrible at doing this, and was hoping for some help / someone to walk me through the best way (most efficient) to complete this task. Perhaps I am going about it the wrong way.
What I have after I scrape (before applying any regex):
Current Conditions at One Location, Evensdale, NC as of 10/30/11 7:03p: Temperature 4.4°C Humidity 92% Dewpoint 3.3°C Wind NNE at 22.5 km/hr Barometer 989.8 hPa & Rising Slowly Wind Chill -1.2°C THW Index -1.2°C Heat Index 4.4°C Today's Rain 35.2 mm Yearly Total 744.6 mm Sunrise: 7:55a Sunset: 6:58p
I then apply the following regex to try and tidy everything up:
$output = preg_replace('/\s\s+\s+\s+\s+\s+/', '<br />', $output);
$output = preg_replace('/\D:/', '<br />', $output, 1);
That gives me something that looks like:
Current Conditions at One Location, Evensdale, NC as of 10/30/11 7:03
Temperature 4.4°C
Humidity 92%
Dewpoint 3.3°C
Wind NNE at 22.5 km/hr
Barometer 989.8 hPa & Rising Slowly Wind Chill -1.2°C
THW Index -1.2°C
Heat Index 4.4°C
Today's Rain 35.2 mm Yearly Total 744.6 mm
Sunrise:
7:55a Sunset:
6:58p
As you can see, the first line truncates early, removing the "p:" from the "7:03". "Wind Chill" and "Yearly Total" are not on their own lines, and the "Sunrise" / "Sunset" fields are also a tad messy.
Any pointers would be helpful!
Cheers