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.

4

2 回答 2

1
$string_to_search = 'whao';
$page = file_get_contents('http://www.example.com/');
echo  substr_count($page, $string_to_search);
于 2015-02-23T04:29:40.850 回答
0

您可以做的是将页面的 htmlsubstr_count作为字符串提供给函数,然后计算该字符串中的出现次数。

于 2015-02-23T04:27:12.673 回答