Hello everyone,

I have a temp/humidity/light sensor in a server room that produces a web page with just raw data like this:

uN703610TF: 79.9HU:36.4%IL: 0.7

That is the only thing on the page, it's wrapped in HTML and BODY tags, but that is it.
What I want to do is to run a script that will parse that into 3 variables.

Let's say they will be $Temp $Hum and $Light
On the above example the Temp would be 79.9 Hum would be 36.4% and Light 0.7

Once they are in their respective variables, I'll put them to a DB and do some charting, but I can not figure out how to get them in variables.

Any help would be greatly appreciated.
Thank you!

Maybe something like this?

$url = "http://localhost/temp-hum-light.html";
$str = file_get_contents($url);

if (preg_match('/(?:uN703610TF:\s*(\d+\.\d*))/', $str, $matches)) {
    $temp = $matches[1];

if (preg_match('/HU:\s*(\d+\.\d*)/', $str, $matches)) {
    $hum = $matches[1];

if (preg_match('/IL:\s*(\d+\.\d*)/', $str, $matches)) {
    $light = $matches[1];

echo '$temp is ' . "$temp\n";
echo '$hum is ' . "$hum\n";
echo '$light is ' . "$light\n";