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

使用する文字エンコーディング名。 省略した場合は内部文字エンコーディングが用いられます。

返り値

needlehaystack の中で最後に現れる位置を返します。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