Drupal Clean CSS Class

A small function which has become a bit of a regular use is Drupal’s Clean CSS Identifier.

“Prepares a string for use as a CSS identifier (element, class, or ID name).”

drupal_clean_css_identifier($identifier, $filter = array(' ' => '-', '_' => '-', '/' => '-', '[' => '-', ']' => ''));

This has become very handy in situations.