Advertisement
Guest User

Untitled

a guest
May 22nd, 2019
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. <?php
  2.  
  3. //$fnlist = array("yandex.htm","RUmetrics.htm");
  4. $fnlist = array("yandex.htm");
  5.  
  6. $string = "";
  7. $td = array(0);
  8.  
  9. $n = count($fnlist);
  10. for ($i=0; $i < $n; $i++)
  11. {
  12. $fname = $fnlist[$i];
  13. $fh = fopen ($fname, "r");
  14. if (!$fh) die("cannot open file $fname");
  15. while (!feof ($fh))
  16. {
  17. $buffer = fgets($fh, 4096);
  18. echo $buffer;
  19. $string .= $buffer;
  20. }
  21. fclose ($fh);
  22.  
  23. $string = strip_tags(stristr($string, "<html"));
  24.  
  25. $keywords = preg_split ("/[\s«»\"\[\]\(\),\.;:\-!\?\/]+/", strtolower($string), -1, PREG_SPLIT_NO_EMPTY);
  26.  
  27. $freq = array_count_values($keywords);
  28.  
  29. while (list($key, $value) = each($freq))
  30. {
  31. if (!array_key_exists($key, $td)) $td[$key] = array_fill(0,$n,0);
  32. $td[$key][$i] = $value;
  33. }
  34.  
  35. }
  36.  
  37. ksort($td);
  38. print "<br><br>\n";
  39. while (list($key, $value) = each($td))
  40. {
  41. print "$key:\t";
  42. for ($i = 0; $i < $n; $i++) print "$value[$i]\t";
  43. print "<br>\n";
  44. }
  45.  
  46.  
  47. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement