Trim unicode whitespace in PHP 5.2

前端 未结 7 1466
隐瞒了意图╮
隐瞒了意图╮ 2020-12-01 09:17

How can I trim a string(6) \" page\", where the first whitespace is a 0xc2a0 non-breaking space?

I\'ve tried trim() and preg_match(\'

相关标签:
7条回答
  • 2020-12-01 10:15

    however here is my ONLY solution, because sometimes there are UTF8 spaces:

    $stringg = preg_replace('/^[\pZ\pC]+|[\pZ\pC]+$/u','',$stringg);
    $stringg = preg_replace('/\s+/u', '', $stringg);
    
    0 讨论(0)
提交回复
热议问题