开发者

How to determine if $match is in $string?

$string = "Test String for the test";
$match = "test string";

How to d开发者_开发知识库etermine if $match is in $string?


You can use stripos to find the position of $match in $string with a case-insensitive search:

$pos = stripos($string, $match);

Note to compare this with a type-safe comparison operator like === or !==. Because if $match is at the begin of $string like in this case, stripos returns 0 and (boolean) 0 === false.


use strpos to check if it is in the string. API Link

For case insensitive, use stripos. API Link


Use stristr($haystack, $needle): http://php.net/manual/en/function.stristr.php

$boolean = stristr($string, $match);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜