Created
January 14, 2017 15:01
-
-
Save tieutantan/8089796d5ed04d3d4fc46f20e487aa68 to your computer and use it in GitHub Desktop.
Remove non-ascii characters from string in php
This file contains hidden or 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 | |
// http://stackoverflow.com/a/8782114 | |
header('Content-Type: text/html; charset=UTF-8'); | |
$str = "abqwrešđčžsff"; | |
$res = preg_replace('/[^\x20-\x7E]/','', $str); | |
echo "($str)($res)"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment