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.

?View Code PHP
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);

This entry was posted on Tuesday, October 21st, 2008 at 10:45 am and is filed under Code. You can follow any responses to this entry through the RSS 2.0 feed. Both comments and pings are currently closed.

« Export MySQL Data to CSV File
MintTv »

Comments are closed.

potatoeskillme
  • Stuff

    • Tioga Pass Eastern Yosemite
    • Mammoth Thanksgiving 2011
    • Road Trip to Monfuckintana
    • Silverton Road Trip 2011
    • Mammoth Thanksgiving 2010
    • Sequoia 2010
    • Big Bear Session
    • Deer Valley Spring Skiing
    • Jackson Hole Road Trip Redux
    • Mammoth Thanksgiving 09
    • NJ Surf Trip Sept 2009
    • Yosemite Aug 2009
    • Big Bear B-day Bash
    • Wedge 7.24.09
    • Morning Surf 7.25.09
    • Morning Surf 7.24.09
    • July 4th, 2009 – 41st Newport
    • Lake Don Pedro
    • Trails Highlights
    • Jackson Hole Road Trip
    • Building a Carputer