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

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

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

Convert any "CamelCased" or "ordinary Word" into an
"underscored_word".

This can be really useful for creating friendly URLs.

@param    string $word Word to underscore

@return string Underscored word
Converts a word into_it_s_underscored_version