1

我想获取两个单词(word1word2)之间的内容(文本),例如:

word1blablabla Poetry can be divided into several genres, or categories. word2 blablabla

所以内容=blablabla Poetry can be divided into several genres, or categories.

但是,有时问题word1andword2可以是大写字母或小写字母。另一个问题是word1仍然打印在结果中。它应该被打印出来。如何处理这个问题?谢谢你 :)

这是代码:

$file = 'word1 blablabla word1 Poetry can be divided into several genres, or categories. word2 blablabla ';
$word1='word1';
$word2='word2';
$between  = substr($file, strpos($file, $word1), strpos($file, $word2) - strpos($file, $word1));
4

1 回答 1

4

您可以使用stripos代替strpos

stripos — 查找字符串中第一次出现不区分大小写的子字符串的位置

于 2012-09-23T09:56:22.027 回答