FOREACH Loop Problem
Posted: Tue Mar 29, 2011 10:30 am
I'm trying to write a script that will check to see if a specifc url is indexed within Google, Yahoo, & Bing.
I've got it to work using a single url, however when I add another url, the problems begin. It doesn't matter if I'm checking 2 or 200 urls, only the last url on the list will work. The others return errors.
Here's my FOREACH LOOP statement (after my variables are set):
I know the variables work (and the code works) for one single url. I just can't seem to get the rest to work.
Any help will be gratefully received...
I've got it to work using a single url, however when I add another url, the problems begin. It doesn't matter if I'm checking 2 or 200 urls, only the last url on the list will work. The others return errors.
Here's my FOREACH LOOP statement (after my variables are set):
Code: Select all
$handle_google = fopen("$google", "r");
$contents_google = stream_get_contents($handle_google);
fclose($handle_google);
if(strstr($contents_google, $needle) !== false) {
echo '<a href="'.$google.'" target="_blank">found</a>';
}
else {
echo 'not found';
}
echo '</td><td>';
$handle_yahoo = fopen("$yahoo", "r");
$contents_yahoo = stream_get_contents($handle_yahoo);
fclose($handle_yahoo);
if(strstr($contents_yahoo, $needle_yahoo) !== false) {
echo '<a href="'.$yahoo.'" target="_blank">found</a>';
}
else {
echo 'not found';
}
echo '</td><td>';
$handle_bing = fopen("$bing", "r");
$contents_bing = stream_get_contents($handle_bing);
fclose($handle_bing);
if(strstr($contents_bing, $needle_bing) !== false) {
echo '<a href="'.$bing.'" target="_blank">found</a>';
}
else {
echo 'not found';
}Any help will be gratefully received...