Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个标题。我想检查指定的字符串是否出现在 php.ini 中的特定字符串之后/之前。
例如,
Title = Director, Employee Representative
我想检查这个词是否Employee出现在标题之后/之前Representative。如果标题包含Representative,检查单词之前/之后的单词是否是Employee
Employee
Representative
怎么做?
一种方法是将其转换为数组,例如:explode(" ","Employee Representative")
explode(" ","Employee Representative")
array( 0 => Employee 1 => Representative )
然后您可以获取您要查找的单词的键(在本例中为 1)并递增或递减它以查看它之前或之后的单词。