preg_replace('/^[\pZ\pC]+|[\pZ\pC]+$/u','',$str);
More Related Contents:
- Trim unicode whitespace in PHP
- How to decode Unicode escape sequences like “\u00ed” to proper UTF-8 encoded characters?
- Matching Unicode letter characters in PCRE/PHP
- Reference: Why are my “special” Unicode characters encoded weird using json_encode?
- preg_match and UTF-8 in PHP
- Fixing broken UTF-8 encoding
- PHP: Convert unicode codepoint to UTF-8
- Storing and displaying unicode string (हिन्दी) using PHP and MySQL
- UTF-8 to Unicode Code Points
- can I get the unicode value of a character or vise versa with php?
- strlen() and UTF-8 encoding
- UTF8 Filenames in PHP and Different Unicode Encodings
- How does source code manage white space and concatenation [duplicate]
- How do I remove  from the beginning of a file?
- How do I use filesystem functions in PHP, using UTF-8 strings?
- How to remove all non printable characters in a string?
- Remove multiple whitespaces
- Convert utf8-characters to iso-88591 and back in PHP
- Any way to return PHP `json_encode` with encode UTF-8 and not Unicode? [duplicate]
- How to get the character from unicode code point in PHP?
- Multibyte trim in PHP?
- convert Persian/Arabic numbers to English numbers
- How to iterate UTF-8 string in PHP?
- URL Decoding in PHP
- Regex for names with special characters (Unicode)
- utf8_(en|de)code removed from php7?
- PHP json_encode json_decode UTF-8
- Ensuring valid UTF-8 in PHP
- UTF-8 in PHP regular expressions [duplicate]
- fwrite() and UTF8