【发布时间】:2015-03-21 03:57:11
【问题描述】:
$string = 'hello world php is a bla bla..';
如何保留'hello world php',通过查找字符串是否包含任何'is',然后删除它后面的所有字符?
我不能使用 substr,因为 'is' 的出现不一致,它也可能是可重复的。第一个怎么抓?
【问题讨论】:
-
给出更多源字符串和目标字符串的例子。你的问题很模糊(“'is'的出现并不一致,也可能是可重复的”???)
-
@colminator 表示它可能是'hello asp hello is my mom and also is etc',你可以看到'is'出现了两次......
-
所以对于“hello asp hello is my mom and is etc”,您想将其映射到“hello asp hello”。对吗?