我想检查一个字符串是否包含在另一个字符串中,然后采取相应的行动。最好的方法是什么? 例如:如果字符串'europe'存在于'europeisthebest'中,则执行某些操作。 if ( isIn('europe', 'europeisthebest') == true){ //do something } 非常感谢!我非常感激您的回答和花费的时间来帮助我。
你正在寻找 strstr()(区分大小写)、stristr()(不区分大小写)或者 strpos()。if (stristr('europeisthebest', 'europe')){ // do something }
if( strpos('blah', 'blah') !== false )
。 - Lusitanian