PHP – mb_strripos() function


The mb_strripos() function in PHP is used to search the last existing of a string in another string. This function is not case-sensitive. It performs multi-byte safe strripos() operation based on the number of characters. It returns the specified needle position count from the starting of the haystack string.

Syntax

integer mb_strripos(
   $str_haystack,
   $str_needle,
   $integer_offset=0,
   $str_encoding
)

Parameters

mb_strripos() accepts the following four parameters −

  • str_haystack − It is the string used to get the position of the last occurrence of the string needle.

  • str_needle − This is used to find the string from the haystack string.

  • integer_offset − This will the needle position in the haystack from where the search should start.

  • str_encoding − It is the character encoding name. If it is omitted, then internal encoding is used.

Return Values

This function returns the numeric position of the last occurrence of the needle in the given haystack string. It returns False if a needle is not found.

Example

<?php
   //UTF-8 Encoding
   //String needle Wo
   //String Hello World
   $string = mb_strripos("Hello World","Wo",0, "UTF-8");

   //Output
   var_dump($string);
?>

Output

int(6)

Updated on: 12-Oct-2021

96 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements