src/Utils/Excerpt.php
/**
     * Find the locations of each of the words.
     * Nothing exciting here. The array_unique is required, unless you decide
     * to make the words unique before passing in.
     */
Find the locations of each of the words.
Nothing exciting here. The array_unique is required, unless you decide
to make the words unique before passing in.
Find the locations of each of the words . Nothing exciting here . The array_unique is required unless you decide to make the words unique before passing in .
protected static function extractLocations(array $words, string $fulltext): array
    {
        $locations = [];
        foreach ($words as $word) {
            $wordLen = mb_strlen($word);
            $loc = mb_stripos($fulltext, $word);
            while ($loc !== false) {
                $locations[] = $loc;
                $loc = mb_stripos($fulltext, $word, $loc + $wordLen);
            }
        }
        $locations = array_unique($locations);
        sort($locations);
        return $locations;
    }
protected static function extractLocations ( array $ words , string $ fulltext ) : array { $ locations = [ ] ; foreach ( $ words as $ word ) { $ wordLen = mb_strlen ( $ word ) ; $ loc = mb_stripos ( $ fulltext , $ word ) ; while ( $ loc !== false ) { $ locations [ ] = $ loc ; $ loc = mb_stripos ( $ fulltext , $ word , $ loc + $ wordLen ) ; } } $ locations = array_unique ( $ locations ) ; sort ( $ locations ) ; return $ locations ; }
Find the locations of each of the words.
Find the locations of each of the words .