-3

当它找到“0”时,我想变得真实,我无法用这些代码做到这一点:

 if (strstr($rSelect['date'],"0") !=FALSE){...}

 if (strpos($rSelect['date'],'0') !=FALSE )
4

4 回答 4

0

尝试 strpos() 了解更多详情http://php.net/manual/en/function.strpos.php

$mystring = $rSelect['date'];
    $findme   = '0';
    $pos = strpos($mystring, $findme);
    if ($pos === false) {
        echo "The string '$findme' was not found in the string '$mystring'";
    } else {
        echo "The string '$findme' was found in the string '$mystring'";
        echo " and exists at position $pos";
    }
于 2013-08-03T04:56:52.307 回答
0

试试喜欢

if (strrchr($rSelect['date'],"0") !== false) {
    echo "No found";
} else {
    echo "Match Found";
}
于 2013-08-03T04:56:57.473 回答
0

strrchr用于检查该字符串中是否存在 0。

if(strrchr('1234', "0") != false) {
    echo 'present';
} else {
    echo 'not present';
}

键盘演示

于 2013-08-03T04:58:15.083 回答
0

只要$rSelect['date']是一个字符串,你的第二种形式是正确的。用于strpos此。

if (strpos($rSelect['date'], '0') !== false) {
    // Do your stuff
}

如果$rSelect['date']数组使用in_array

if (in_array('0', $rSelect['done'])) {
    // Do your stuff
}
于 2013-08-03T05:00:36.573 回答