PHP mb_strrichr() Function Last Updated : 28 Apr, 2025 Comments Improve Suggest changes Like Article Like Report The mb_strrichr() function is a case-insensitive in-built function. This function searches a multi-byte string for the last occurrence of a specified character and returns the portion of the string. Syntax: mb_strrichr( $haystack, $needle, $before_needle , $encoding) : string|falseParameters: This function accepts 4 parameters that are described below. $haystack: This parameter specifies retrieving the last occurrence of the needle from the string.$needle: The character or string search in $haystack.$before_needle: If "true", the function returns the portion of the string that precedes $needle instead of the portion that follows it. The default is "false".$encoding: This is an optional parameter with the character encoding of the string. If not provided, internal encoding is used.Return Values: The mb_strrichr() function returns the portion of the string that follows or precedes the last occurrence of the specified character or substring, depending on the value of the $before_needle parameter. If the character or substring is not found, the function returns “false”. Example 1: The following program demonstrates the mb_strrichr() function. PHP <?php $str = "Hello, world!"; $needle = ","; $portion = mb_strrichr($str, $needle); echo $portion; ?> Output, world!Example 2: The following program demonstrates the mb_strrichr() function. PHP <?php $haystack = "Hello, world!"; $needle = "o"; $lastOccurrence = mb_strrichr($haystack, $needle); if ($lastOccurrence !== false) { echo "The last occurrence of '$needle' in the haystack is: $lastOccurrence"; } else { echo "The needle '$needle' was not found in the haystack."; } ?> OutputThe last occurrence of 'o' in the haystack is: orld!Reference: https://www.php.net/manual/en/function.mb-strrichr.php Comment More infoAdvertise with us Next Article PHP mb_strrichr() Function neeraj3304 Follow Improve Article Tags : PHP PHP-Multibyte-String Similar Reads PHP strrchr Function The strrchr() function is a built-in function in PHP. This function takes two arguments a string and a character. This function searches the given character in the given string and returns the portion of string starting from the last occurrence of the given character in that string. Syntax: strrchr( 2 min read PHP mb_stristr() Function The mb_stristr() is an inbuilt function in PHP that is used to get the first occurrence of a string within another string. It will check case insensitivity. Syntax:mb_stristr( $haystack, $needle, $before_needle, $encoding = null ): string|falseParameters: This function accepts 4 parameters that are 2 min read PHP mb_strripos() Function The mb_strripos() function is a PHP inbuilt case-insensitive function that is utilized to find the position for the last occurrence of a string inside another string. Syntax: mb_strripos($haystack, $needle, $offset = 0,encoding = null): int|falseParameters: This function accepts four parameters desc 2 min read PHP mb_strstr() Function The mb_strstr() function is an inbuilt function in PHP that finds the first occurrence of a given string in the main string, i.e. it will search for the occurrence of the first needle in haystack, & id found then the portion of the haystack will be returned, otherwise return false. Syntax: mb_st 2 min read PHP mb_strimwidth() Function The mb_strimwidth() function is an inbuilt function in PHP that returns the truncated string for the specified width. Syntax: string mb_strimwidth($string, $start, $width, $trim_marker, $encoding )Parameters: This function accepts five parameters that are described below: $string: This parameter spe 2 min read PHP mb_strpos() Function The mb_strpos() function is an inbuilt function in PHP that finds the position of string occurrence in the string. Syntax: mb_strpos( $haystack, $needle, $offset, $encoding ): int|falseParameters: This function accepts 4 parameters that are described below: $haystack: This parameter is the main stri 2 min read PHP mb_strlen() Function The mb_strlen() is an inbuilt PHP function that returns the string length in an integer. Syntax: mb_strlen($string, $encoding ): intParameters: This function accepts 2 parameters that are described below: $string: The string parameter whose lengths need to be determined. It is a required parameter.$ 1 min read PHP stristr() Function The stristr() function is a built-in function in PHP. It searches for the first occurrence of a string inside another string and displays the portion of the latter starting from the first occurrence of the former in the latter (before if specified). This function is case-insensitive. Syntax : strist 2 min read PHP strtr() Function The strtr() is an inbuilt function in PHP which is used to replace a substring in a string to a given string of characters. It also has the option to change a particular word to a different word in a string. The function is case sensitive. Syntax: strtr($string, $string1, $string2) or, strtr($string 4 min read PHP | ob_start() Function Let's take a quick recap. PHP is an interpreted language thus each statement is executed one after another, therefore PHP tends to send HTML to browsers in chunks thus reducing performance. Using output buffering the generated HTML gets stored in a buffer or a string variable and is sent to the buff 2 min read Like