PHP stripos

原创
2016-06-08 17:28:59 976浏览

PHP stripos

stripos() 函数返回字符串在另一个字符串中第一次出现的位置。与strpos(),stripos()不区分大小写

string 必需。规定被搜索的字符串。
find 必需。规定要查找的字符。
start 可选。规定开始搜索的位置。

$findme = 'a';
$mystring1 = 'xyz';
$mystring2 = 'ABC';

$pos1 = stripos($mystring1, $findme);
$pos2 = stripos($mystring2, $findme);

// Nope, 'a' is certainly not in 'xyz'
if ($pos1 === false) {
echo "The string '$findme' was not found in the string '$mystring1'";
}

// Note our use of ===. Simply == would not work as expected
// because the position of 'a' is the 0th (first) character.
if ($pos2 !== false) {
echo "We found '$findme' in '$mystring2' at position $pos2";
}
?>

strpos() - 查找的字符串的第一个出现的位置
strrpos() - 查找字符串中的字符的最后出现的位置
strrchr() - 查找字符串中的字符最后一次出现
substr() - 返回字符串的一部分
stristr() - 忽略大小写strstr
strstr() - 查找第一次出现的字符串
strripos() - 找出案件的最后出现的位置在一个字符串不敏感的字符串
str_ireplace() - 病例的str_replace区分版本。

声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn核实处理。
上一条:php closedir 函数 下一条:php城市无限分类

相关文章

查看更多