I don't know what you mean by sort the words by common to least common. But here's the code(except that part):
PHP Code:
<?php
$common = array('is','the','that','them','and','he');
$find = array(' ', ',,');
$replace = array(',', ',');
$truncate = 5;
//no editting below
$truncate++;
if(isset($_POST['submit'])){
$content = str_replace($common, "", $_POST['content']);
$content = str_replace($find, $replace, $content);
$content = explode(',', $content);
foreach($content as $key => $value){
$arr_search = array_search($value, $content);
if($arr_search != $key){
unset($content[$arr_search]);
}
}
$new_content = array();
if(count($content) > $truncate){
for($i=0; $i<$truncate; $i++){
$new_content[] = $content[$i];
}
} else {
$new_content = $content;
}
echo implode(',', $new_content);
}
?>
<form action="<?php echo $_SERVER["PHP_SELF"]; ?>" method="post">
<textarea name="content" style="font-family: arial; height: 250px; width: 500px;"></textarea>
<br />
<input type="submit" name="submit" />
</form>
Bookmarks