I'm trying to get it to remove any anchor tag that is a local link but it's not working. Here's the code.
Code: Select all
<form method="get" action="pod_search3.php" name="pod_search">
<input type="text" name="terms" id="terms" />
<input type="hidden" name="target" id="target" value="http://www.google.com/search" />
<input type="submit" value="find mph-cast" />
</form>
Thanks,
<?php
$search_terms = $_GETї'terms'];
$target_engine = $_GETї'target'];
$search_terms = str_replace(" ", "+", $search_terms);
$guy = web_search($search_terms, $target_engine);
function web_search($terms, $target)
{
if($terms)
{
$query = array();
$query = "$target?hl=en&num=100&li=&q=$terms";
print($query . "<br>");
$result = file_get_contents($query);
// gets all anchor tags on page
$pattern = '/(<a .*<\/a>)/i';
preg_match_all($pattern, $result, $links);
$pagelinks = array();
$num = 0;
// here is the part that's not working
for($i=0;$i<count($linksї0]);$i++)
{
// what I am trying to say in the next line is, "if http:// is not in the
// next element, do nothing. otherwise add it to a new array.
if(!strstr("http://", $linksї0]ї$i])) ;
else {
$pagelinksї$num] = $linksї0]ї$i];
print($pagelinksї0]); //($pagelinksї$num] . "<br />");
$num++;
}
}
/*foreach($linksї0] as $link)
{
//works
print("$num - " . $link . "<br />");
++$num;
}*/
}
else print("enter search term");
}
?>Code: Select all
continue...and sorry about the half post. I was trying to make my code more legible by taking out the comments and erased the problem bit.
Thanks