Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/290.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 测试字符串集合中是否存在子字符串_Php_Substring - Fatal编程技术网

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

我想使用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 ($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功能可能会重复