本文介紹了在 PHP 5.2 中修剪 unicode 空格的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
如何修剪 string(6) " page"
,其中第一個空格是 0xc2a0 不間斷空格?
How can I trim a string(6) " page"
, where the first whitespace is a 0xc2a0 non-breaking space?
我試過 trim()
和 preg_match('/^s*(.*)s*$/u', $key, $m);代碼>.
另一個問題:我怎樣才能可靠地復制這些字符?它們似乎被轉換為正常"空間,這使得調試變得困難.
Another question: How can I reliably copy these characters? They seem to be converted to "normal" spaces, which makes it hard to debug.
推薦答案
preg_replace('/^[pZpC]+|[pZpC]+$/u','',$str);
這篇關于在 PHP 5.2 中修剪 unicode 空格的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!