Php 测试字符串集合中是否存在子字符串
我想使用php测试子字符串是否在字符串中 比如说,Php 测试字符串集合中是否存在子字符串,php,substring,Php,Substring,我想使用php测试子字符串是否在字符串中 比如说, $str="Cycle"; $str1="Cycle,Yoga"; 我想检查是否(str1中的str)使用stripos if (stripos($str1,$str) !== false) { echo 'true'; } 使用strpos或stripos $mystring = 'Cycle,Yoga'; $findme = 'Cycle'; $pos = strpos($mystring, $findme); if ($p
$str="Cycle";
$str1="Cycle,Yoga";
我想检查
是否(str1中的str)
使用stripos
if (stripos($str1,$str) !== false) {
echo 'true';
}
使用strpos或stripos
$mystring = 'Cycle,Yoga';
$findme = 'Cycle';
$pos = strpos($mystring, $findme);
if ($pos !== false) {
echo "true";
}
使用(区分大小写的字符串)或(不区分大小写的)进行字符串匹配
if (strpos($str1,$str) !== false) {
// It'll check the case-sensitivity of string
echo 'true';
}
if (stripos($str1,$str) !== false) {
// It'll ignore the case-sensitivity
echo 'true';
}
使用STRPO或strstr功能可能会重复