[英]String matching in php not working correctly?
stristr($post['message'],$t1)=== FALSE
给出结果列表但我需要stristr($post['message'],$t1)=== TRUE
,只给出1个结果! 帮助PLZ。,
码:
foreach($page_posts['data'] as $post){
if(!(stristr($post['message'],$t1)=== FALSE) && $t1!==" ")
{
$message = (($post['message']) ? $post['message'] : " ");
$i++;
print($message);
}
与stristr($post['message'],$t1)=== TRUE
相同stristr($post['message'],$t1)=== TRUE
ie; 只给出一个结果〜
stristr不会返回布尔值TRUE ...当找到您要查找的字符串时,它将返回字符串。 否则,它将返回布尔值FALSE。
所以用stristr测试($ post ['message'],$ t1)=== TRUE是错误的。
使用stripos,而不是stristr。
if(stripos($post['message'], $t1) > -1) {
// needle is in haystack
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.