阅读量:136
stripos()是PHP中的字符串函数,用于在字符串中查找子字符串的位置(不区分大小写)。它的定义和用法如下:
定义:
int stripos ( string $haystack , mixed $needle [, int $offset = 0 ] )
参数:
-
haystack:要在其中查找子字符串的主字符串。
-
needle:要查找的子字符串。
-
offset(可选):从主字符串的指定位置开始查找。
返回值:
返回子字符串第一次出现的位置。如果找不到子字符串,则返回false。
用法示例:
<?php $str="Hello, world!" ;="" $pos="stripos($str," "hello");="" 查找子字符串"hello"在$str中的位置="" if="" ($pos="" !="=" false)="" {="" echo="" "substring="" found="" at="" position="" "="" .="" $pos;="" }="" else="" {="" echo="" "substring="" not="" found";="" }=""?>输出:
Substring found at position 0