lib/Inflector/Methods.php
public static function underscore($camel_cased_word){
		$word = $camel_cased_word;
		$word = preg_replace('/\\\/', '/', $word);
		$acronym_regex = static::inflections()->acronym_regex;
		$word = preg_replace_callback("/(?:([A-Za-z\d])|^)({$acronym_regex})(?=\b|[^a-z])/", function($matches){
			return "{$matches[1]}" . ($matches[1] ? '_' : '') . strtolower($matches[2]);
		}, $word);
		$word = preg_replace('/([A-Z\d]+)([A-Z][a-z])/','$1_$2', $word);
		$word = preg_replace('/([a-z\d])([A-Z])/','$1_$2', $word);
		$word = strtr($word, '-', '_');
		$word = strtolower($word);
		return $word;
	}
public static function underscore($camel_cased_word){
		$word = $camel_cased_word;
		$word = preg_replace('/\\\/', '/', $word);
		$acronym_regex = static::inflections()->acronym_regex;
		$word = preg_replace_callback("/(?:([A-Za-z\d])|^)({$acronym_regex})(?=\b|[^a-z])/", function($matches){
			return "{$matches[1]}" . ($matches[1] ? '_' : '') . strtolower($matches[2]);
		}, $word);
		$word = preg_replace('/([A-Z\d]+)([A-Z][a-z])/','$1_$2', $word);
		$word = preg_replace('/([a-z\d])([A-Z])/','$1_$2', $word);
		$word = strtr($word, '-', '_');
		$word = strtolower($word);
		return $word;
	}
public static function underscore ( $ camel_cased_word ) { $ word = $ camel_cased_word ; $ word = preg_replace ( '/\\\/' , '/' , $ word ) ; $ acronym_regex = static :: inflections ( ) -> acronym_regex ; $ word = preg_replace_callback ( "/(?:([A-Za-z\d])|^)({$acronym_regex})(?=\b|[^a-z])/" , function ( $ matches ) { return "{$matches[1]}" . ( $ matches [ 1 ] ? '_' : '' ) . strtolower ( $ matches [ 2 ] ) ; } , $ word ) ; $ word = preg_replace ( '/([A-Z\d]+)([A-Z][a-z])/' , '$1_$2' , $ word ) ; $ word = preg_replace ( '/([a-z\d])([A-Z])/' , '$1_$2' , $ word ) ; $ word = strtr ( $ word , '-' , '_' ) ; $ word = strtolower ( $ word ) ; return $ word ; }
Makes an underscored, lowercase form from the expression in the string.

Changes '\' to '/' to convert namespaces to paths.

Examples:
underscore("ActiveRecord")         # => "active_record"
underscore("ActiveRecord\Errors")  # => "active_record/errors"

As a rule of thumb you can think of +underscore+ as the inverse of +camelize+,
though there are cases where that does not hold:

camelize(underscore("SSLError")) # => "SslError"

@param string $camel_cased_word
@return string Underscored $camel_cased_word
@author Koen Punt
Makes an underscored lowercase form from the expression in the string .