PHP 字符串 strripos()函數(shù)
strripos()是PHP的預(yù)定義字符串函數(shù)。愛掏網(wǎng) - it200.com它用于查找一個(gè)字符串在另一個(gè)字符串中最后出現(xiàn)的位置。愛掏網(wǎng) - it200.com
Strripos(string,find,start);
參數(shù) | 描述 | 必需/可選 |
---|---|---|
string | 指定要搜索的字符串。愛掏網(wǎng) - it200.com | 必需 |
find | 指定要查找的字符串。愛掏網(wǎng) - it200.com | 必需 |
start | 指定搜索的起始位置。愛掏網(wǎng) - it200.com | 可選 |
函數(shù)strripos()返回字符串最后一次出現(xiàn)的位置,如果未找到字符串則返回FALSE。愛掏網(wǎng) - it200.com字符串位置從0開始而不是1。愛掏網(wǎng) - it200.com
注意:strripos()函數(shù)是不區(qū)分大小寫的。愛掏網(wǎng) - it200.com
示例1
<?php
echo "By using 'strripos()' function: ".strripos("Hello php,Hello php and Javascript!","PHP")
?>
輸出:
By using 'strripos()' function: 16
示例2
<?php
haystack = 'ababcd';needle = 'aB';
pos = strripos(haystack, needle);
if (pos === false) {
echo "Sorry, we did not find (needle) in (haystack)";
} else {
echo "Congratulations!\n";
echo "We found the last (needle) in (haystack) at position ($pos)";
}
?>
輸出:
Congratulations!
We found the last (aB) in (ababcd) at position (2)
參見:
- stripos() :用于返回一個(gè)字符串在另一個(gè)字符串中第一次出現(xiàn)的位置。愛掏網(wǎng) - it200.com
- strpos() :用于返回一個(gè)字符串在另一個(gè)字符串中第一次出現(xiàn)的位置。愛掏網(wǎng) - it200.com
- strrchr() :用于找到一個(gè)字符串在另一個(gè)字符串中最后一次出現(xiàn)的位置。愛掏網(wǎng) - it200.com
- strrev() :用于反轉(zhuǎn)一個(gè)字符串。愛掏網(wǎng) - it200.com
參考:
http://php.net/manual/en/function.strripos.php
聲明:所有內(nèi)容來(lái)自互聯(lián)網(wǎng)搜索結(jié)果,不保證100%準(zhǔn)確性,僅供參考。如若本站內(nèi)容侵犯了原著者的合法權(quán)益,可聯(lián)系我們進(jìn)行處理。