Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Articles by Urmila Samariya
Page 2 of 11
PHP – mb_strimwidth (multybyte strimwidth) function
The mb_strimwidth() function in PHP is used to truncate a multibyte string to a specified width. This function is particularly useful for handling text in different character encodings while maintaining proper string length control. Syntax string mb_strimwidth($str, $start, $width, $trimmarker, $encoding) Parameters mb_strimwidth() accepts five parameters to control string truncation − $str − The input string to be truncated. $start − Starting position for truncation (0-based index). $width − Maximum width of the truncated string. Negative values count from the end. $trimmarker − String appended when truncation occurs (optional). $encoding − Character ...
Read MorePHP – mb_preferred_mime_name() function
The mb_preferred_mime_name() function in PHP is used to return the MIME charset string for a character encoding. It gets a MIME (Multipurpose Internet Mail Extensions) charset string for the specific encoding. Syntax string mb_preferred_mime_name(string $encoding) Parameters mb_preferred_mime_name() accepts only one parameter − $encoding − The character encoding name to get the MIME charset string for. Return Value The function returns the MIME charset string for the given encoding, or false if no preferred MIME name exists for the encoding. Example 1: Basic Usage Let us see how ...
Read MorePHP – Parse the GET, POST, and COOKIE data using mb_parse_str()
The mb_parse_str() function in PHP is used to parse URL-encoded data (commonly from GET, POST, and COOKIE) and converts it into an array. It automatically detects the encoding and converts it to the internal encoding, making it useful for handling multibyte character strings. Syntax bool mb_parse_str(string $encoded_string, array &$result) Parameters The mb_parse_str() function accepts the following parameters − $encoded_string − The URL-encoded data string to be parsed. $result − An array that will hold the parsed key-value pairs after decoding and character conversion. Return Values The function returns true ...
Read MorePHP – Get or set the HTTP output character encoding with mb_http_output()
The mb_http_output() function in PHP is used to get or set the HTTP output character encoding. An output, after this function is called, will be converted from the set internal encoding to the specified encoding. Syntax string|bool mb_http_output(string $encoding = null) Parameters mb_http_output() accepts only a single parameter − $encoding − It is used to set the HTTP output character encoding to the encoding. If the encoding is omitted, then mb_http_output() will return the current HTTP output character encoding. ...
Read MorePHP – Detect HTTP input character encoding with mb_http_input()
The mb_http_input() function in PHP is used to detect the HTTP input character encoding from various sources like GET, POST, COOKIE data, and strings. This function is particularly useful when working with different character encodings in web applications and is supported in PHP 5.4 or higher. Syntax array|string mb_http_input(string $type = null) Parameters mb_http_input() accepts a single optional parameter − $type − Specifies the input type to check for character encoding: G − GET variables P − POST variables C − COOKIE variables S − String variables L − List of ...
Read MorePHP – Get the internal settings of mbstring with mb_get_info()
The mb_get_info() function in PHP is used to get the internal settings of mbstring extension. This function is supported in PHP 5.4 or higher version and is essential for debugging and understanding current multibyte string configurations. Syntax array|string|int mb_get_info(string $type = "all") Parameters It accepts only a single parameter to get the multibyte information. $type − If the type parameter is not specified or it is specified as "all", then it will return all available mbstring settings. If a specific type is provided, it returns only that setting value. Available type values ...
Read MorePHP – mb_ereg_replace() function – Replace regular expression with multibyte support
In PHP, mb_ereg_replace() is used to replace a regular expression with multibyte support. It scans the string for matches to pattern, then replaces the matched text with the replacement, making it ideal for handling international characters and Unicode strings. Syntax string mb_ereg_replace(string $pattern, string $replacement, string $string, string $options = null) Parameters The function accepts the following four parameters − $pattern − The regular expression pattern. It may use multibyte characters in the pattern. $replacement − The replacement text used to replace the matched pattern. $string − The input string to be ...
Read MorePHP – mb_ereg_replac_callback() function
In PHP, mb_ereg_replace_callback() function is used to perform a regular expression search and replace with multibyte support using a callback. It scans strings, matches them with a pattern, then replaces the matched text with the output of the callback function. This function is similar to mb_ereg_replace() but allows custom replacement logic through callbacks. It is supported in PHP 5.4 or higher versions. Syntax string mb_ereg_replace_callback(str $pattern, callback $callback, str $string, str $options) Parameters The function accepts the following four parameters − $pattern − The regular expression pattern. May use multibyte characters. $callback ...
Read MorePHP – Match regular expression using mb_ereg_match()
In PHP, the mb_ereg_match() function is used for matching a given string with a regular expression pattern. This function only matches the string from the beginning and returns true if a match is found, else it returns false. It supports multibyte character sets, making it useful for international text processing. Syntax bool mb_ereg_match(string $pattern, string $string, string $options = null) Parameters It accepts the following three parameters − $pattern − The regular expression pattern to match against. $string − The input string being evaluated. ...
Read MorePHP – Get aliases of a known encoding type using mb_encoding_aliases()
In PHP, mb_encoding_aliases() is used to get the aliases of a known encoding type. This function returns all alternative names for a specified character encoding, which is useful when working with different systems that may use varying naming conventions for the same encoding. Syntax array mb_encoding_aliases(string $encoding) Parameters $encoding − The encoding type to check for aliases. This must be a valid encoding name recognized by the mbstring extension. Return Value Returns a numerically indexed array of encoding aliases on success, or false on failure. Errors/Exceptions If the encoding is ...
Read More