2017-02-05 34 views
-2

我有一個字符串,我想從字符串中刪除'是'字,因爲我正在使用修剪功能。但是我沒有得到理想的結果。修剪()函數不工作在php

這是我的代碼。

<?php 
    $string1 = "Life is chess."; 
    $string3 = trim($string1,"is"); 
    echo $string3; 
?> 

我得到的輸出作爲Life is chess.

請在下面評論任何查詢。

回答

3

trim()函數從字符串的開頭或結尾刪除空格或其他字符。如果你需要從字符串中刪除字符,你需要使用別的東西。例如,您可以使用str_replace

str_replace('is', '', 'this is string');