PHP:在字符串中搜索字符串

inr*_*rob 0 php string replace find

我想检查另一个字符串中是否存在字符串,然后执行相应的操作.做这个的最好方式是什么?

例如; 如果字符串'europe'出现在'europeisthebest'中,那就做点什么吧.

if ( isIn('europe', 'europeisthebest') == true){
  //do something
}
Run Code Online (Sandbox Code Playgroud)

非常感谢!我很感谢你所有的答案和花在帮助上的时间.

Joh*_*nde 5

你正在寻找strstr()(区分大小写),stristr()(不区分大小写),或strpos()

if (stristr('europeisthebest', 'europe')){
  // do something
}
Run Code Online (Sandbox Code Playgroud)