how to rplace file_get_contents with curl

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Jonathan_Allen
Forum Newbie
Posts: 1
Joined: Fri Jun 25, 2010 10:09 am

how to rplace file_get_contents with curl

Post by Jonathan_Allen »

here's the parcer

Code: Select all

<?php
$url = "http://site.com";
$unique_start = "<tr><td><noindex>";
$unique_end = "</a></td>";
function weather($url, $unique_start, $unique_end) {
$code = file_get_contents($url);
preg_match_all('/'.preg_quote($unique_start,'/').'(.*)'.preg_quote($unique_end, '/').'/Us', $code, $match);
return implode("<br>", $match[1]);
if (preg_match_all('/'.preg_quote($unique_start,'/').'(.*)'.preg_quote($unique_end, '/').'/Us', $code, $match))
    print_r($match);
else
    echo 'sry I cant find a thing';
}
echo weather($url, $unique_start, $unique_end); ?> 
So, tell me please how to replace file_get_contents with curl
User avatar
Jonah Bron
DevNet Master
Posts: 2764
Joined: Thu Mar 15, 2007 6:28 pm
Location: Redding, California

Re: how to rplace file_get_contents with curl

Post by Jonah Bron »

The third result looks good.

http://lmgtfy.com/?q=php+curl
Post Reply