This is two simple functions that I always use for content grabbing from another website. Easy to use, with sample.
Here are the two main functions:
<?php
// get content of URL into string
function getContentOfURL($url){
$file = fopen($url, "r");
if($file){
while (!feof ($file)) {
$line .= fread ($file, 1024*50);
}
return $line;
}
return false;
}
// get value of text inbetween tags
function getContentByTag($tag1,$tag2,$string) {
if (eregi("$tag1(.*)$tag2", $string, $out)) {
$outdata = $out[1];
}
return $outdata;
}
?>
Here are the examples to get value of <title></title> tags from Google.com: