-
-
Save justinhernandez/d4a273378c50ceca18f54b58f5c0586f to your computer and use it in GitHub Desktop.
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 | |
$testString = "• janky • stuff • take me away ••"; | |
function escape_mb_chars($str) { | |
$first = preg_replace_callback('/\p{C}/u', function ($m) { | |
$char = current($m); | |
return substr(json_encode($char), 1, -1); | |
}, $str); | |
return rtrim($first, '\n'); | |
} | |
function clean_string($str) { | |
return preg_replace('/[^a-zA-Z0-9\s]/', '', $str); | |
} | |
print clean_string($testString) . "\n"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment