本文介紹了在 PHP 5.2 中修剪 unicode 空格的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!
問(wèn)題描述
如何修剪 string(6) " page"
,其中第一個(gè)空格是 0xc2a0 不間斷空格?
How can I trim a string(6) " page"
, where the first whitespace is a 0xc2a0 non-breaking space?
我試過(guò) trim()
和 preg_match('/^s*(.*)s*$/u', $key, $m);代碼>.
另一個(gè)問(wèn)題:我怎樣才能可靠地復(fù)制這些字符?它們似乎被轉(zhuǎn)換為正常"空間,這使得調(diào)試變得困難.
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);
這篇關(guān)于在 PHP 5.2 中修剪 unicode 空格的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!
【網(wǎng)站聲明】本站部分內(nèi)容來(lái)源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問(wèn)題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(lián)系我們刪除處理,感謝您的支持!