PHP cURL
A useful PHP snippit – cURL is a multi-protocol server communication library. The code below grabs the data of a url and stores each line in an array.
1 2 3 4 5 6 7 8 9 | $url = "http://google.com"; $ch = curl_init(); $timeout = 60; // set to zero for no timeout curl_setopt ($ch, CURLOPT_URL, $url); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout); $rawdata= explode("\n", curl_exec($ch)); curl_close($ch); unset($ch); |