Revision: 48672
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at July 7, 2011 14:15 by alyssonweb
Initial Code
if ( ! function_exists( 'to_friendly_string' ) ) :
function to_friendly_string( $phrase = '', $maxLength = false ) {
if ( empty( $phrase ) )
return '';
$result = strtolower( $phrase );
$result = trim( preg_replace( "/&{1}(amp;)?/", ' and ', $result ) );
$result = trim( preg_replace( "/[^a-z0-9\s-]/", '', $result ) );
$result = trim( preg_replace( "/[\s-]+/", ' ', $result ) );
if ( $maxLength )
$result = trim( substr( $result, 0, $maxLength ) );
$result = preg_replace( "/\s/", "-", $result );
return $result;
}
endif;
Initial URL
Initial Description
Convert a string to friendly string.
Initial Title
To Friendly String
Initial Tags
url
Initial Language
PHP