Created
February 22, 2010 00:31
-
-
Save luisuribe/310646 to your computer and use it in GitHub Desktop.
Clean Up Text
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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