-3

I am getting a webpage using file_get_contents();:

$file = file_get_contents('http://example.com');

How do I check if the webpage contains the text 'hello' or 'bye'

bob jomes
  • 271
  • 1
  • 4
  • 13
  • 1
    Possible duplicate of [Check if string contains specific words?](http://stackoverflow.com/questions/4366730/check-if-string-contains-specific-words) – piedar Aug 15 '16 at 20:37

2 Answers2

1
$file = file_get_contents('http://example.com');
$exists = (strpos($file, 'hello') !== false) || (strpos($file, 'bye') !== false);
if ($exists !== false) {
    print 'Found';
}
Kamrul Khan
  • 3,260
  • 4
  • 32
  • 59
0
$file = file_get_contents('http://example.com');
if (strpos($file, 'hello') !== false)
{
    echo "Exist..";
}
KmasterYC
  • 2,294
  • 11
  • 19