PHP - 从字符串中删除所有选项卡 [英] PHP - Remove all tabs from string
本文介绍了PHP - 从字符串中删除所有选项卡的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我能够从字符串中删除所有单个选项卡:
I am able to remove all single tabs from a string:
// Copying and pasting the tab directly
$txt = str_replace(" ", "", $txt);
这只会删除单个标签,但不会删除双标签.然后我尝试了这个,认为 "\t" 就足以找到标签:
This only removes single tabs, but not double tabs. I then tried this, thinking that "\t" would be sufficient to find the tabs:
$txt = preg_replace('/\t/', '', $txt);
然而,它没有用.谁能提供更好的东西?
However, it didn't work. Can anyone offer something better?
推荐答案
trim(preg_replace('/\t+/', '', $string))
这篇关于PHP - 从字符串中删除所有选项卡的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文