我想刪除括號內的值,只是它包含"eur" AND "%"
但開始時很難,因爲爆炸字符串"("
沒有讓我走得很遠。PHP - 如果條件爲真,刪除括號內的值
例子:
"T-Shirt(grey)(20EUR excl.10% discount)with print" -> "T-Shirt(grey)with print"
"Jacket(blue)" -> "Jacket(blue)"
我的初步嘗試:
$string="T-Shirt(grey)(20EUR excl.10% discount)with print";
$string = explode("(",$string);
foreach($string as $first){
if(strlen(stristr($first,'eur'))!=0 AND strlen(stristr($first,'%'))!=0){
}
}
請展示一些先前的嘗試。 – mario
你的if語句返回true,所以問題不在這裏。 –