private function extractLocations(array $words, $fulltext)
    {
        $locations = [];
        foreach ($words as $word) {
            $wordLen = strlen($word);
            $loc = stripos($fulltext, $word);
            while ($loc !== false) {
                $locations[] = $loc;
                $loc = stripos($fulltext, $word, $loc + $wordLen);
            }
        }
        $locations = array_unique($locations);
        sort($locations);

        return $locations;
    }
private function extractLocations(array $words, $fulltext)
    {
        $locations = [];
        foreach ($words as $word) {
            $wordLen = strlen($word);
            $loc = stripos($fulltext, $word);
            while ($loc !== false) {
                $locations[] = $loc;
                $loc = stripos($fulltext, $word, $loc + $wordLen);
            }
        }
        $locations = array_unique($locations);
        sort($locations);

        return $locations;
    }
private function extractLocations ( array $ words , $ fulltext ) { $ locations = [ ] ; foreach ( $ words as $ word ) { $ wordLen = strlen ( $ word ) ; $ loc = stripos ( $ fulltext , $ word ) ; while ( $ loc !== false ) { $ locations [ ] = $ loc ; $ loc = stripos ( $ fulltext , $ word , $ loc + $ wordLen ) ; } } $ locations = array_unique ( $ locations ) ; sort ( $ locations ) ; return $ locations ; }
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.

@param array  $words
@param string $fulltext

@return array
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 .