function search_index_split

search_index_split($text, $langcode = NULL)

Simplifies and splits a string into words for indexing.

Parameters

string $text: Text to process.

string|null $langcode: Language code for the language of $text, if known.

Return value

array Array of words in the simplified, preprocessed text.

See also

search_simplify()

File

core/modules/search/search.module, line 361
Enables site-wide keyword searching.

Code

function search_index_split($text, $langcode = NULL) {
  $last = &drupal_static(__FUNCTION__);
  $lastsplit = &drupal_static(__FUNCTION__ . ':lastsplit');

  if ($last == $text) {
    return $lastsplit;
  }
  // Process words
  $text = search_simplify($text, $langcode);
  $words = explode(' ', $text);

  // Save last keyword result
  $last = $text;
  $lastsplit = $words;

  return $words;
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!modules!search!search.module/function/search_index_split/8.1.x