Created
March 3, 2011 10:23
-
-
Save jonasbjork/852588 to your computer and use it in GitHub Desktop.
Snippet for removing illegal chars from a string.
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 | |
// Remove illegal chars, replacing them with a dash (-) | |
$str = "abc är du här? eLLller ELLER kanske däår?"; | |
$str = preg_replace('/[^0-9a-zA-Z]+/', '-', $str); | |
// results in -> "abc-r-du-h-r-eLLller-ELLER-kanske-d-r-" | |
echo $str.PHP_EOL; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment