1

I'm trying to figure out how search for the number of occurrence for a keyword on a php webpage. Not a string but count the occurrences and then post the number, for how many times a certain number appears on the page. Are there any functions for this.

The only related function I see is "substr_count". Again I don't want to count the occurrences in a string but a whole page.

Jeremy Huddleston Sequoia
  • 22,938
  • 5
  • 78
  • 86
Fonzworth
  • 13
  • 2

2 Answers2

1
$string_to_search = 'whao';
$page = file_get_contents('http://www.example.com/');
echo  substr_count($page, $string_to_search);
Adrian Cid Almaguer
  • 7,815
  • 13
  • 41
  • 63
0

What you can do is feed the html of the page into the function substr_count as a string and then count the occurrences in that string.

winhowes
  • 7,845
  • 5
  • 28
  • 39