public function parseWords($string, $searches) { // IWords[] $wordsStats = array(); // String[] $words = array(); // remove close bracket $string = trim($string, ']'); // remove open bracket $string = trim($string, '['); preg_match_all($this->_pattern, $string, $words); $matches = array(); if (preg_match_all($this->_pattern, $string, $matches)) { $words = $matches[0]; foreach ($words as $word) { $wordInstance = new Word($word); $wordInstance->setCount(1); $wordInstance->setExactSearches($searches); $wordsStats[] = $wordInstance; } } return $wordsStats; }