Hello, the following script does NOT work on my server that is running php5.
I need it to work on BOTH php4 and PHP5....
Thanks!
<?php
$sitecontents = "Funny text, other text and other content and other stuff goes here.";
$commonwords = <<<EOF
other goes here ' - \\
EOF;
$parsearray[] = $sitecontents;
$parsestring = "z ".strtolower(join($parsear
ray," "))." y";
$parsestring = str_replace (",", "", $parsestring);
$parsestring = str_replace ("\n", "", $parsestring);
$parsestring = str_replace (")", "", $parsestring);
$parsestring = str_replace ("(", "", $parsestring);
$parsestring = str_replace (".", "", $parsestring);
$parsestring = str_replace ("'", "", $parsestring);
$parsestring = str_replace ('"', "", $parsestring);
$commonarray = split(" ",$commonwords);
for ($i=0; $i<count($commonarray); $i++) {
$parsestring = str_replace (" ".$commonarray[$i]." ", " ", $parsestring);
}
$parsestring = str_replace (" ", " ", $parsestring);
$parsestring = str_replace (" ", " ", $parsestring);
$parsestring = str_replace (" ", " ", $parsestring);
$wordsarray = split(" ",$parsestring);
for ($i=0; $i<count($wordsarray); $i++) {
$word = $wordsarray[$i];
if ($freqarray[$word]) {
$freqarray[$word] += 1;
} else {
$freqarray[$word]=1;
}
}
arsort($freqarray);
$i=0;
while (list($key, $val) = each($freqarray)) {
$i++;
$freqall[$key] = $val;
if ($i==15) {
break;
}
}
for ($i=0; $i<count($wordsarray)-1; $i++) {
$j = $i+1;
$word2 = $wordsarray[$i]." ".$wordsarray[$j];
if ($freqarray2[$word2]) {
$freqarray2[$word2] += 1;
} else {
$freqarray2[$word2]=1;
}
}
arsort($freqarray2);
$i=0;
while (list($key, $val) = each($freqarray2)) {
$i++;
$freqall[$key] = $val;
if ($i==4) {
break;
}
}
for ($i=0; $i<count($wordsarray)-2; $i++) {
$j = $i+1;
$word3 = $wordsarray[$i]." ".$wordsarray[$j]." ".$wordsarray[$j+1];
if ($freqarray3[$word3]) {
$freqarray3[$word3] += 1;
} else {
$freqarray3[$word3]=1;
}
}
arsort($freqarray3);
$i=0;
while (list($key, $val) = each($freqarray3)) {
$i++;
$freqall[$key] = $val;
if ($i==1) {
break;
}
}
arsort($freqall);
while (list($key, $val) = each($freqall)) {
$pagecontents .= "$key => $val<br>";
$keys .= $key.", ";
}
chop($keys);
$pagecontents . = $keys;
echo $pagecontents;
?>
Start Free Trial