Last active
March 3, 2016 09:25
-
-
Save Isinlor/64b164cd213bc194dd38 to your computer and use it in GitHub Desktop.
Two functions to work with unicode whitespaces. See: http://php.net/manual/en/regexp.reference.unicode.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 | |
$compactWhitespace = function ($string) { | |
return preg_replace('/[\pZ\pC]+/u', ' ', $string); | |
}; | |
$trim = function ($string) { | |
return preg_replace('/^[\pZ\pC]+|[\pZ\pC]+$/u', '', $string); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment