I need to split this string into different section to gather particular data so that I can store it in a database with PHP. I am after some help to either split or use a regex to gather this data reliably. Not all the values will be the same length, so need a way to test for each part without just splitting based on character position.
Sol 1565 (Dec 31, 2016): Sunny, high -6C/21F, low -72C/-97F, pressure at 8.74 hPa, daylight 06:25-18:41
I want to get these separate values:
- Sol 1565 (This will always start with Sol and be followed by a 4 digit number)
- Dec 31, 2016 (The date format will always be M d, Y)
- Sunny (A word will always be used, but may not be the same word)
- -6C [high] (The high temp in C)
- 21F [high] (The high temp in F)
- -72C [low] (The low temp in C)
- -97F [low] (The low temp in F)
- 8.74 (The pressure - will be a float)
- 06:25 (daytime start)
- 18:41 (daytime finish)
I have tried using
substr, but soon worked out it would not be reliable. So after a solution that would be more suitable.