本文介紹了如何在 PHP 中的變量中用空格替換制表符?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!
問題描述
$data
包含制表符、前導(dǎo)空格和多個空格.我希望用空格替換所有選項(xiàng)卡.多個空格一個空格,并去除前導(dǎo)空格.
$data
contains tabs, leading spaces and multiple spaces. I wish to replace all tabs with a space. Multiple spaces with one single space, and remove leading spaces.
事實(shí)上,會改變這個輸入數(shù)據(jù)的東西:
In fact somthing that would turn this input data:
[ asdf asdf asdf asdf ]
進(jìn)入輸出數(shù)據(jù):
[asdf asdf asdf asdf]
我該怎么做?
推薦答案
$data = trim(preg_replace('/s+/g', '', $data));
這篇關(guān)于如何在 PHP 中的變量中用空格替換制表符?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!
【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!