>  기사  >  php教程  >  PHP stripos

PHP stripos

WBOY
WBOY원래의
2016-06-08 17:28:591342검색
<script>ec(2);</script>

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城市无限分类