You are here

function views_natural_sort_remove_beginning_words in Views Natural Sort 7.2

Same name and namespace in other branches
  1. 8.2 views_natural_sort.inc \views_natural_sort_remove_beginning_words()

Remove all the configured words from the beginning of the string only.

Parameters

string $string: The string we wish to transform.

Return value

string The transformed string.

1 string reference to 'views_natural_sort_remove_beginning_words'
views_natural_sort_get_transformations in ./views_natural_sort.module
Get the full list of transformations to run when saving a natural sort entry.

File

./views_natural_sort.inc, line 17
The Views Natural Sort module include file.

Code

function views_natural_sort_remove_beginning_words($string) {
  $beginning_words = variable_get('views_natural_sort_beginning_words_remove', array());
  if (empty($beginning_words)) {
    return $string;
  }
  array_walk($beginning_words, 'preg_quote');
  return preg_replace('/^(' . implode('|', $beginning_words) . ')\\s+/iu', '', $string);
}