Hi there folks!
I'm working on a "similar links" function and plan on first stripping the common search stop words out of the string and then using similar_text to find the most similar links in the database. I'm doing fine on the tests, but currently am using a prepared array for the stop words and would instead like to modify the check to utilize a list of words contained in an easily managed text file.
Currently, I'm testing like this:
$string = 'After sustaining a life changing injury in 2013, Martyn Ashton, mountain bike and Road Bike Party legend, is Back On Track.';
$stopwords = array("able", "about", "above", "abroad", "according", "accordingly", "across", "actually", "adj", "after", "afterwards", "again", "against");
foreach ($stopwords as &$word) {
$word = '/\b' . preg_quote($word, '/') . '\b/';
}
$useful_words = preg_replace($stopwords, '', $string);
And I would like to instead do the match incorporating a file with just a list of words each separated by a new line so I can easily modify the list without having to deal with quotes and commas:
[ in the file ]
able
about
above
abroad
according
accordingly
across
actually
adj
after
afterwards
again
against
Could someone help me with how I might achieve this? Thanks for your time!