目前我正在使用 strstr() 获取字符串的第一部分。我的项目在 3 台服务器上运行。1. 开发服务器 2. 测试服务器 3. 实时服务器
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"]);
在第一台和第二台服务器上,我得到了这个:apple 在我的第三台服务器上,我什么也没得到。
有没有另一种方法可以删除最后一部分,所以我只得到苹果?(我不想在“-”上这样做,因为有一个变化,我将有其他带有多个“-”的字符串。例如:apple - cake - <fruit<
(我知道fruit也写为:<fruit>,但带有striptags,或striptext 是行不通的)。
那么有人可以帮我解决这个烦人的小问题吗?非常感谢您!