PHP mb_stripos() Function Last Updated : 01 Aug, 2023 Comments Improve Suggest changes Like Article Like Report The mb_stripos() function is an inbuilt case-insensitive function that finds the first occurrence of a substring in the string. Syntax: int|false mb_stripos( string $haystack, string $needle, int $offset , ?string $encoding);Parameters: This function accepts 4 parameters that are described below. $haystack: This parameter is the main string parameter where we check the string.$needle: This parameter is searching string parameter in the main string.$offset: This parameter is an optional parameter. It is used for defining where you are to start searching string in the $haystack parameter.$encoding: This parameter is also optional. It is used for defining an encoding by using the mb_internal_encoding() function.Return Values: This function returns the integer of the first occurrence of $needle in the $haystack parameter. If $needle is not found in the $haystack parameter, it will return “false”. Program 1: The following code demonstrates the mb_stripos() function. PHP <?php $string = "Hello World"; $sub = "WORLD"; $result = mb_stripos($string, $sub); if ($result !== false) { echo "Substring '$sub' found in '$string'"; } else { echo "Substring '$sub' not found in '$string'"; } ?> OutputSubstring 'WORLD' found in 'Hello World' Program 2: The following program demonstrates the mb_stripos() function. PHP <?php $string = "This is a test string"; $substring = "ing"; $position = mb_stripos($string, $substring); // Output the position echo $position; ?> Output18 Program 3: The following program demonstrates the mb_stripos() function PHP <?php $string = "She sells seashells by the seashore."; $substring = "S"; $position = 0; $occurrences = 0; while (($position = mb_stripos($string, $substring, $position)) !== false) { $occurrences++; $position = $position + mb_strlen($substring); } echo "The substring '$substring' was "+ "found $occurrences times in the string."; ?> OutputThe substring 'S' was found 8 times in the string. Reference: https://www.php.net/manual/en/function.mb-stripos.php Comment More infoAdvertise with us Next Article PHP mb_stripos() Function N neeraj3304 Follow Improve Article Tags : PHP PHP-function PHP-Multibyte-String Similar Reads 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_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_strrichr() Function 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 f 2 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 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 Like