You are here

function signup_id_safe in Signup 5

Same name and namespace in other branches
  1. 5.2 signup.module \signup_id_safe()
  2. 6.2 signup.module \signup_id_safe()
  3. 6 signup.module \signup_id_safe()
  4. 7 signup.module \signup_id_safe()

Converts an arbitrary string into something safe to use for a CSS id.

Stolen wholesale from the Zen theme. ;)

See also

zen_id_safe()

1 call to signup_id_safe()
theme_signup_custom_data in ./signup.module
Renders custom signup user data into a human-readable format.

File

./signup.module, line 1517

Code

function signup_id_safe($string) {

  // Replace with dashes anything that isn't a-zA-Z, numbers, dashes, or
  // underscores.
  $string = drupal_strtolower(preg_replace('/[^a-zA-Z0-9_-]+/', '-', $string));

  // If the first character is not a-z, add 'id' in front.
  // Don't use ctype_alpha since it's locale aware.
  if (!ctype_lower($string[0])) {
    $string = 'id' . $string;
  }
  return $string;
}