每日分享PHP知识点,大家都赞同关注是一种动力,分享是一种美德,再说了关注分享一下又不会怀孕?只要你开心就好...... strripos()计算指定字符串在目标字符串中最后一次出现的位置(不区分大小写)。 int strripos ( string $haystack , string $needle [, int $offset = 0 ] ) 说明: 以不区分大小写的方式查找指定字符串在目标字符串中最后一次出现的位置。与 strrpos() 不同,strripos() 不区分大小写。 参数描述 haystack 在此字符串中进行查找。 needle 注意 needle 可以是一个单字符或者多字符的字符串。 offset 参数 offset 可以被指定来查找字符串中任意长度的子字符串。 负数偏移量将使得查找从字符串的起始位置开始,到 offset 位置为止。 返回值: 返回 needle 相对于 haystack 字符串的位置(和搜索的方向和偏移量无关)。同时注意字符串的起始位置为 0 而非 1。 如果 needle 未被发现,返回 FALSE。 实例1: $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) ?> 输出: //Congratulations! //We found the last (aB) in (ababcd) at position (2)
关注是一种动力? 分享是一种美德? 关注分享一下又不会怀孕!
|