Jump to content

check if a certain string is in a page ..


Recommended Posts

depends on which version of php you have...

 

<?php
$file = 'PATH/TO/FILE';
if (function_exists('file_get_contents'))
{
$string = file_get_contents($file)
}
else
{
$fp = fopen($file,'rb');
$string = fread($fp,filesize($file));
fclose($fp);
}

if (preg_match('/ASTRING/i',$string))
{
echo 'found string';
}
?>

 

 

yes, file_get_contents does work on my server.. so i have this.. but it returns "string not found" ...

 

<?php
$file = 'htp://myspace.com'; //Might this be the problem? does external URLs work?

$string = file_get_contents($file);

if(preg_match('/Home/i',$string)){
echo 'found string';
}else{
echo 'string not found';
}
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.