目前我正在使用strstr()獲取字符串的第一部分。我有我的項目在3臺服務器上運行。 1.開發服務器 2.測試服務器 3. Live服務器strstr php或替代部分字符串
值strstr()工作正常開發服務器和測試服務器上,但現在我把我的項目現場,在打印的strstr什麼。例如:
我用這個代碼:
//$product["titel2"] = "apple - <fruit<";
$product["titel2"]=(strstr($product["titel2"], "<domino"))?strstr($product["titel2"], "<fruit",true):$product["titel2"];
$str_product_titel = stripText(!empty($product["titel"]) && preg_match("/^<!--/",stripText($product["titel"]))==0?$product["titel"]."":$product["titel2"]);
在第一和第二個服務器我得到這個: 蘋果 在我的第三個服務器我什麼也沒得到。
是否有另一種方法來刪除最後一部分,所以我只得到蘋果? (我不想在「 - 」上做,因爲有一個變化,我將有其他字符串與多個「 - 」在其中。例如:蘋果蛋糕 - &#60fruit &#60
(我知道水果也被寫爲:<水果>,但striptags,或striptext這是行不通的)
所以有人可以幫我這個小惱人的問題 非常感謝你提前
?!
我認爲發生爆炸:
無論如何,你可以使用類似老年PHP版本效仿。 – ajreal 2011-12-27 08:57:47
將您的實施放在一邊,您的原始要求究竟是什麼? – 2011-12-27 08:57:48