Skip to content

Instantly share code, notes, and snippets.

@luisuribe
Created February 22, 2010 00:31
Show Gist options
  • Save luisuribe/310646 to your computer and use it in GitHub Desktop.
Save luisuribe/310646 to your computer and use it in GitHub Desktop.
Clean Up Text
<?php
/**
*
* @author nebiros
*/
class App_Util
{
public function cleanUpText( $input, $lowercase = true, $glue = "-" )
{
if ( true === empty( $input ) )
{
return null;
}
if ( true === $lowercase )
{
$input = strtolower( $input );
}
return preg_replace( "/[^a-zA-Z0-9_]/", "", preg_replace( "/\s+/", $glue, $input ) );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment