我有大约 1000 个不同的句子。我想从这些句子中删除“DLC”一词,但“All DLC BG”和“DLC Comfort”片段除外,因此不应从这两个片段中删除“DLC”一词。
我想这里需要array()
,但我不知道该怎么做。
我试过这样的:
if (stripos($title, 'All DLC BG') && stripos($title, 'DLC Comfort') == false) {
$title = str_ireplace("DLC ", " ", $title);
}
但不起作用。
最佳答案
您快完成了,但是您需要检查两个操作的 bool 条件并使用三等号来完成:
if (stripos($title, 'All DLC BG') === false && stripos($title, 'DLC Comfort') === false) {
$title = str_ireplace("DLC ", "", $title);
}
另外我认为你想替换为空字符串,而不是一个空格。
关于php - 从句子中删除除选定单词之外的单词,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55552178/