Filter text and load into an array
This is how you can filter a text and load it into an array. This function converts all words into lower-case, removes all HTML tags, junk characters and numbers, explode it in to an array and finally removes duplicates.
<?php
function get_words($text) {
$text = mb_strtolower($text, 'UTF-8');
$text = strip_tags($text);
$RemoveChars[] = "([,.:;!?()#&%+*\"'])";
$RemoveChars[] = "/ - /";
$RemoveChars[] = "([0-9])";
$RemoveChars[] = '/'.chr(13).'/';
$RemoveChars[] = '/'.chr(10).'/';
$RemoveChars[] = '/'.chr(9).'/';
$ReplaceWith = " ";
$text = preg_replace($RemoveChars, $ReplaceWith, $text);
$words = explode(" ", $text);
$words = array_filter($words);
return $words;
}
?>
Knowledge keywords: