public static function removeStopWords($string, $asString = false)
    {
        $delimiters = preg_quote(static::$delimiters, '/');
        $stopWords = explode(',', static::$stopWords);

        $result = array_map(function ($token) {
            return $token;
        }, array_filter(
            array_map(function ($t) {
                return mb_strtolower($t, 'UTF-8');
            }, preg_split("/[\\s$delimiters]+/", $string, -1, PREG_SPLIT_NO_EMPTY)),
            function ($word) use ($stopWords) {
                return !in_array($word, $stopWords);
            }
        ));
        if ($asString) {
            return implode(' ', $result);
        }

        return $result;
    }
public static function removeStopWords($string, $asString = false)
    {
        $delimiters = preg_quote(static::$delimiters, '/');
        $stopWords = explode(',', static::$stopWords);

        $result = array_map(function ($token) {
            return $token;
        }, array_filter(
            array_map(function ($t) {
                return mb_strtolower($t, 'UTF-8');
            }, preg_split("/[\\s$delimiters]+/", $string, -1, PREG_SPLIT_NO_EMPTY)),
            function ($word) use ($stopWords) {
                return !in_array($word, $stopWords);
            }
        ));
        if ($asString) {
            return implode(' ', $result);
        }

        return $result;
    }
public static function removeStopWords ( $ string , $ asString = false ) { $ delimiters = preg_quote ( static :: $ delimiters , '/' ) ; $ stopWords = explode ( ',' , static :: $ stopWords ) ; $ result = array_map ( function ( $ token ) { return $ token ; } , array_filter ( array_map ( function ( $ t ) { return mb_strtolower ( $ t , 'UTF-8' ) ; } , preg_split ( "/[\\s$delimiters]+/" , $ string , - 1 , PREG_SPLIT_NO_EMPTY ) ) , function ( $ word ) use ( $ stopWords ) { return ! in_array ( $ word , $ stopWords ) ; } ) ) ; if ( $ asString ) { return implode ( ' ' , $ result ) ; } return $ result ; }
Remove stop words

@param $string
@param bool $asString

@return array|string
Remove stop words