2017-05-08 38 views
1

刪除&NBSP我需要更換由'單一空間&nbsp &nbsp這是我的字符串如何從字符串

To Everything There is a Season     For everything there is a season, and a time for every purpose under heaven:     

它應該是這樣的

To Everything There is a Season For everything there is a season, and a time for every purpose under heaven 
+2

沒有嘗試'str_replace'? – Thamilan

+1

我試過preg_replace它在我的本地但不是在服務器中刪除 –

+2

嘗試'str_replace'這是解決這個問題的最好方法。 –

回答

3

試試這個

$text = str_replace('&nbsp','',$your_string); 
0

// str_replace()函數; $ newStr = str_replace(' ','','your string');

0

試試這個:

$str  = "To Everything There is a Season     For everything there is a season, and a time for every purpose under heaven:    "; 
$order = array("    ", "  "); 
$replace = ''; 

$newstr = str_replace($order, $replace, $str); 

您可以再次使用str_replace的「:」在你的字符串的結尾

0

的str_replace()函數函數替換一些字符在一些其他字符串。

語法: str_replace函數(查找,替換字符串,計數)

echo str_replace(" "," ","To Everything There is a Season     For everything there is a season, and a time for every purpose under heaven:    "); 

你可以得到更多的幫助,在這裏:str_replace