利用php现成的函数,制作关键字密度查询
[font=NSimsun][code] <?php?yx2DNtVB7e tb&\function str_exists($item,$key,$keyword){
global $i;TZ6GP6U*E$`,y
if(preg_match("/$keyword/i",$item)){
$i++;
}:N[5Dv!b
}
function clean_html($str){
return preg_replace("/<\/[^>]+>|<[^\s]+\s|\'|\"|<[a-z]+>/i",'',$str);
}3_'v'v5EW_W
s[0G8Hd){
function count_density($item,$key,$sum){sEz"N9H
if($item>0)7LO7v8vd$R%j
echo "
F,x)CT%x6X
$item times of $key, with the frequency of".number_format(($item/$sum)*100,2)."8MI_ ?"]([4cr
"; } $site=$_POST['site']; if(strpos($site,'http://')===false){ $site="http://".$site; } $keyword=trim($_POST['keyword']); $str=file_get_contents($site); $str1=clean_html($str); $a1=str_word_count($str1,1,$keyword);//获得所有的英语单词 arsort($a1); $i=0; array_walk($a1,'str_exists',$keyword); $coo=count($a1); echo "$i times of $keyword,with the frequency of :".number_format(($i/$coo)*100,2).'%';
?>[/code][/font]ITQ N%n_
演示地址:[url=http://blog.zenme.org/demo/keyword_dentiry.php][color=#800080]http://blog.zenme.org/demo/keyword_dentiry.php[/color][/url]+~%]J;y!A@
有好的建议,欢迎跟我联系.QQ:628558
页:
[1]

