1 token.inc token_clean_token_name($name)

Prepare a string for use as a valid token name.

Parameters

string $name: The token name to clean.

Return value

string The cleaned token name.

File

core/includes/token.inc, line 720
Backdrop placeholder/token replacement system.

Code

function token_clean_token_name($name) {
  static $names = array();

  if (!isset($names[$name])) {
    $cleaned_name = strtr($name, array(' ' => '-', '_' => '-', '/' => '-', '[' => '-', ']' => ''));
    $cleaned_name = preg_replace('/[^\w\-]/i', '', $cleaned_name);
    $cleaned_name = trim($cleaned_name, '-');
    $names[$name] = $cleaned_name;
  }

  return $names[$name];
}