downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | conferences | my php.net

search for in the

mb_strrpos> <mb_strrichr
[edit] Last updated: Fri, 17 May 2013

view this page in

mb_strripos

(PHP 5 >= 5.2.0)

mb_strripos大小写不敏感地在字符串中查找一个字符串最后出现的位置

说明

int mb_strripos ( string $haystack , string $needle [, int $offset = 0 [, string $encoding ]] )

mb_strripos() 基于字符数执行一个多字节安全的 strripos() 操作。 needle 的位置是从 haystack 的开始进行统计的。 第一个字符的位置是 0,第二个字符的位置是 1。 和 mb_strrpos() 不同的是, mb_strripos() 是大小写不敏感的。

参数

haystack

查找 needle 在这个字符串中最后出现的位置。

needle

haystack 中查找这个字符串。

offset

haystack 中开始搜索的位置。

encoding

使用的字符编码名称。如果省略了,则将使用内部编码。

返回值

返回字符串 haystackneedle 最后出现位置的数值。 如果没有找到 needle,它将返回 FALSE

参见

  • strripos() - 计算指定字符串在目标字符串中最后一次出现的位置(不区分大小写)
  • strrpos() - 计算指定字符串在目标字符串中最后一次出现的位置
  • mb_strrpos() - 查找字符串在一个字符串中最后出现的位置



add a note add a note User Contributed Notes mb_strripos - [1 notes]
up
0
easai
2 years ago
Here are Java like startsWith/endsWith implementations in PHP.

<?php
   
function startsWith($haystack,$needle)
    {
     
$res=FALSE;
      if(
mb_strripos($haystack,$needle,0,"utf-8")==0)
        
$res= TRUE;
      return
$res;
    }

    function
endsWith($haystack,$needle)
    {
     
$res=FALSE;
     
$len=mb_strlen($haystack);
     
$pos=$len-mb_strlen($needle);
      if(
mb_strripos($haystack,$needle,0,"utf-8")==$pos)
        
$res= TRUE;
      return
$res;
    }
?>

 
show source | credits | sitemap | contact | advertising | mirror sites