2014-11-06 72 views
1

這組字符串來自我的xml提要。我想從PROPERTY FEATURES中刪除部分:到最後。我非常需要你的幫助。PHP如何從短語中刪除特定的字符串/單詞?

Semi fitted office for sale in Tower with partition and kichen 

    PROPERTY FEATURES: 
    -Basement parking 
    -Central air conditioning 
    -Covered parking 

應該是...

Semi fitted office for sale in Tower with partition and kichen 

感謝。任何幫助將非常感激。

+0

使用['strpos'(http://www.php.net/strpos)得到的'PROPERTY FEATURES'的位置,並使用['substr'] (http://www.php.net/substr)剪切原始字符串。 – h2ooooooo 2014-11-06 06:57:49

回答

0
$foundAt = strpos($string, 'PROPERTY FEATURES'); 
$new = substr($string,0,$foundAt); 
echo $new; 
0

嘗試:

$str = '//your string'; 
$new = substr($str, 0, strpos($str, 'PROPERTY')); 
var_dump($new); 
相關問題