目前我正在使用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