#!/usr/bin/php \n"; } else { fwrite($fp, "GET / HTTP/1.0\r\nHost: " . $addr . "\r\nAccept: */*\r\n\r\n"); while (!feof($fp)) { $line = fgets($fp, 1024); //time is available in all received records, that is the filter word //for sensor data if(str__contains($line,"time")) { //raw output of json print_r($line); /* do something with content of $line for example decode $line into an array $arr = json_decode($line,true); do something with that array and output into a file as json file_put_contents('test.json', json_encode($arr, JSON_PRETTY_PRINT); */ } } fclose($fp); } ?>