strrpos() 函数用于定位字符串最后一次出现的位置,返回整型。
语法:
int strpos ( string string, mixed needle [, int start] )
strrpos() 函数用法与 strpos() 类似,只不过 strrpos() 用于取得指定字串最后出现的位置。
例子:
<?php
$str = "This function returns the last occurance of a string";
$pos = strrpos($str, "st");
if($pos !== FALSE){
echo '字串 st 最后出现的位置是:',$pos;
} else {
echo '查找的字符串中没有 in 字串';
}
?>
运行该例子,浏览器输出:
字串 st 最后出现的位置是:46