Created
October 25, 2012 13:47
-
-
Save Stichoza/3952636 to your computer and use it in GitHub Desktop.
A simple PHP function to strip strings and numbers.
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 | |
function strip_string($str, $case) { | |
switch ($case) { | |
case "az": return preg_replace("/[^a-zA-Z]+/", "", $str); | |
case "num": return preg_replace("/[^0-9]+/", "", $str); | |
case "num+az": default: return preg_replace("/[^a-zA-Z0-9]+/", "", $str); | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment