public static function hyphenize($word)
    {
        $regex1 = preg_replace('/([A-Z]+)([A-Z][a-z])/', '\1-\2', $word);
        $regex2 = preg_replace('/([a-z])([A-Z])/', '\1-\2', $regex1);
        $regex3 = preg_replace('/([0-9])([A-Z])/', '\1-\2', $regex2);
        $regex4 = preg_replace('/[^A-Z^a-z^0-9]+/', '-', $regex3);

        return strtolower($regex4);
    }
public static function hyphenize($word)
    {
        $regex1 = preg_replace('/([A-Z]+)([A-Z][a-z])/', '\1-\2', $word);
        $regex2 = preg_replace('/([a-z])([A-Z])/', '\1-\2', $regex1);
        $regex3 = preg_replace('/([0-9])([A-Z])/', '\1-\2', $regex2);
        $regex4 = preg_replace('/[^A-Z^a-z^0-9]+/', '-', $regex3);

        return strtolower($regex4);
    }
public static function hyphenize ( $ word ) { $ regex1 = preg_replace ( '/([A-Z]+)([A-Z][a-z])/' , '\1-\2' , $ word ) ; $ regex2 = preg_replace ( '/([a-z])([A-Z])/' , '\1-\2' , $ regex1 ) ; $ regex3 = preg_replace ( '/([0-9])([A-Z])/' , '\1-\2' , $ regex2 ) ; $ regex4 = preg_replace ( '/[^A-Z^a-z^0-9]+/' , '-' , $ regex3 ) ; return strtolower ( $ regex4 ) ; }
Converts a word "into-it-s-hyphenated-version"

Convert any "CamelCased" or "ordinary Word" into an
"hyphenated-word".

This can be really useful for creating friendly URLs.

@param    string $word Word to hyphenate

@return string hyphenized word
Converts a word into - it - s - hyphenated - version