phpbb\search\fulltext_postgres::split_message PHP Method

split_message() public method

Turns text into an array of words
public split_message ( string $text )
$text string contains post text/subject
    public function split_message($text)
    {
        // Split words
        $text = preg_replace('#([^\\p{L}\\p{N}\'*])#u', '$1$1', str_replace('\'\'', '\' \'', trim($text)));
        $matches = array();
        preg_match_all('#(?:[^\\p{L}\\p{N}*]|^)([+\\-|]?(?:[\\p{L}\\p{N}*]+\'?)*[\\p{L}\\p{N}*])(?:[^\\p{L}\\p{N}*]|$)#u', $text, $matches);
        $text = $matches[1];
        // remove too short or too long words
        $text = array_values($text);
        for ($i = 0, $n = sizeof($text); $i < $n; $i++) {
            $text[$i] = trim($text[$i]);
            if (utf8_strlen($text[$i]) < $this->config['fulltext_postgres_min_word_len'] || utf8_strlen($text[$i]) > $this->config['fulltext_postgres_max_word_len']) {
                unset($text[$i]);
            }
        }
        return array_values($text);
    }