You are here

public static function SuggestionHelper::atomize in Autocomplete Search Suggestions 7

Transform a string to an array.

Parameters

string $txt: The string to process.

Return value

array An array of atoms.

2 calls to SuggestionHelper::atomize()
SuggestionHelper::insert in src/SuggestionHelper.php
Add a suggestion.
suggestion_surfer_submit in ./suggestion.module
Custom submit function to add surfer suggestions.

File

src/SuggestionHelper.php, line 68
Helper methods for the suggestion module.

Class

SuggestionHelper
Provides helper methods for suggestions.

Code

public static function atomize($txt = '') {
  $atoms = array();
  $stopwords = self::getStops('stopwords');
  foreach (preg_split('/\\s+/', $txt) as $atom) {
    if (!empty($stopwords[$atom])) {
      continue;
    }
    $atoms[$atom] = $atom;
  }
  return $atoms;
}