Removes spaces, other junk and prevents double dashes.
<?php
// call this way to make menu items
// $css_id = toCSSid(strip_tags($link))."-menu";
function toCSSid($css_id) {
// this should convert accented chars to their base (untested)
if (function_exists('iconv')) {
$css_id = @iconv('UTF-8', 'ASCII//TRANSLIT', $css_id);
}
$css_id = str_replace(array(" ", " "), '-', $css_id);
$css_id = preg_replace("/[^a-zA-Z0-9 -]/", "", $css_id); //allow only a-Z, integers and dashes Read more »