PHP mb_strimwidth() Function Last Updated : 26 Apr, 2023 Summarize Comments Improve Suggest changes Share Like Article Like Report 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 specifies the string that will be trimmed.$start: This is the starting point where you start the trim. The beginning of the string (index starts from 0). If the start initializes negative, it will start from the ending of the string.$width: This parameter specifies the desired width of the trimmed string. In case, if the with is negative then the count will be from the end of the string.$trim_maker: This parameter specifies a string is added to the end of the trimmed string.$encoding: The character encoding is to be used. By default, it will use UTF-8. The encoding parameter denotes the character encoding. If omitted or null, then the internal character encoding value will be utilized.Return Values: This function returns the truncated string. Example 1: The following program demonstrates the mb_strimwidth() function. PHP <?php $str = "This is a very long string that needs to be trimmed"; $trimmed_str = mb_strimwidth($str, 0, 20, "..."); echo $trimmed_str; ?> Output: This is a very lo... Example 2: The following program demonstrates the mb_strimwidth() function. PHP <?php $str = "Geeks for Geeks Matter"; $trimmed_str = mb_strimwidth($str, -5,5 , "Gee"); echo $trimmed_str; ?> Output: atter Reference: https://www.php.net/manual/en/function.mb-strimwidth.php Comment More infoAdvertise with us Next Article PHP mb_strpos() Function N neeraj3304 Follow Improve Article Tags : PHP PHP-function PHP-Multibyte-String Similar Reads 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_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 trim() Function The trim() function in PHP is an inbuilt function which removes whitespaces and also the predefined characters from both sides of a string that is left and right. Related Functions: PHP | ltrim() Function PHP | rtrim() Function Syntax: trim($string, $charlist) Parameters:The function accepts one man 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 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 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 Like