<?php
// Build the list of words and convert everything to lowercase.
$string =
strtolower('<MTEntries lastn="9999"><$MTEntryKeywords remove_html="1" encode_php="q"$> </MTEntries>');
// Remove punctuation.
//$wordlist = preg_split('/\s*[\s+\.|\?|,|(|)|\-+|\'|\"|=|;|×|\$|\/|:|{|}]\s*/i', $string);
$wordlist =
preg_split('/\s+|,/i',
$string);
// Build an array of the unique words and number of times they occur.
$a =
array_count_values( $wordlist );
// Sort the keys alphabetically.
ksort( $a );
// Print the data.
echo '<p style="background-color: #EEEEFF; padding:1em">';
// Assign a font-size to the word based on frequency of use.
foreach ($a as $word =>
$count) {
if ($count <=
1) { $size =
50;
} elseif ($count <=
3) { $size =
75;
} elseif ($count <=
5) { $size =
100;
} elseif ($count <=
10) { $size =
125;
} elseif ($count <=
25) { $size =
150;
} elseif ($count <=
50) { $size =
175;
} elseif ($count <=
75) { $size =
200;
} elseif ($count <=
100) { $size =
225;
} elseif ($count <=
125) { $size =
250;
} elseif ($count <=
140) { $size =
275;
} elseif ($count <=
155) { $size =
300;
} elseif ($count <=
170) { $size =
325;
} elseif ($count <=
200) { $size =
350;
} elseif ($count <=
225) { $size =
375;
} elseif ($count <=
250) { $size =
400;
} elseif ($count <=
275) { $size =
425;
}
// The keyword needs to be referenced 2 or more times to register.
if ($count >=
2) {
echo ' <span style="font-size: ' .
$size .
'%;"><a title="List of all ' .
$count .
' entries tagged with ' .
$word .
'" rel="nofollow" href="/<$MTSearchScript$>?Template=technometria&IncludeBlogs=<$MTBlogID$>&SearchElement=keywords&search=' .
$word .
'">' .
$word .
'</a></acronym></span> ';
}
}
echo '</p>';
?>