Found 1046 Articles for PHP

PHP – mb_strrpos() function

Urmila Samariya
Updated on 11-Oct-2021 13:44:01

176 Views

The mb_strrpos() function in PHP is used to find the position of the last occurrence of a string in another string. This function performs the multibyte safe strrpos() operation based on the number of characters. It counts the needle position from the starting of the haystack string.Syntaxint mb_strrpos( $str_haystack, $str_needle, $int_offset=0, $str_encoding=empty )Parametersmb_strrpos() accepts the following four parameters −$str_haystack − This parameter is used to check the string for the last existence of the needle string.$str_needle − This needle parameter is used to find the string in the ... Read More

PHP – mb_stristr() function

Urmila Samariya
Updated on 11-Oct-2021 13:40:34

103 Views

The mb_stristr() function in PHP is used to search the first existence of a string in another given string; this function is not case-sensitive. mb_stristr() searches for the first existence of the needle in a given haystack string and returns the portion of the haystack. It will return False if the needle is not found.Syntaxstring mb_stristr( $str_haystack, $str_needle, $bool_before_needle=false, $str_encoding=empty )Parametersmb_stristr() accepts the following four parameters −$str_haystack − This parameter is used to get the first existence of the string needle.$str_needle − This parameter is used to find ... Read More

PHP – mb_stripos() function

Urmila Samariya
Updated on 11-Oct-2021 13:38:47

317 Views

The mb_stripos() function in PHP is used to find the position of first occurrence of a string within another string. It is "case-insensitive". mbstripos() returns the numeric position of the first existence of the needle in a given haystack string. If the needle is not found, it will return False.Syntaxinteger mb_stripos($str_haystack, $str_needle, $int_offset=0, $str_ecoding=empty)ParametersIt accepts the following four parameters −$str_haystack − This parameter is used to get the position of the first existence of the needle from the given string.$str_needle − This parameter is used to find the string from the given haystack.$int_offset − This parameter is used to search ... Read More

PHP – mb_strrchr() function

Urmila Samariya
Updated on 11-Oct-2021 13:37:14

95 Views

The mb_strrchr() function in PHP checks the last occurrence of a character in a given string within another string. For example, suppose we have a string "ia" and we need to check it from another given string "PHP tutorials", then the mb_strrchr() function will return the portion of characters till the last existence character "ials". If it is not found, then it will return false.SyntaxString mb_strrchr($str_haystack, $str_needle, $bool_before_needle=false, $str_encoding=empty)Parametersmb_strrchr() accepts the following four parameters −$str_haystack − This parameter is used to get the last existence of the string needle.$str_needle − This parameter is used to find the string in a ... Read More

PHP – mb_strimwidth (multybyte strimwidth) function

Urmila Samariya
Updated on 11-Oct-2021 13:32:09

638 Views

The mb_strimwidth() function in PHP is used to truncate a given string with specified width. It is used to cut out the specified width from a given string.Syntaxstring mb_strimwidth($str_string, $int_start, $int_width, $str_trim_marker, $str_encoding)For example, mb_strimwidth($str_string: "PHP Tutorials", $int_start: 2, $int_width: 10, $str_trim_marker: "...", ); Parametersmb_strimwidth() accepts five different parameters to trim the string width.$str_string − The string that is to be decoded.$int_start − This integer parameter will trim the string from the specified start position. It will trim the string of characters from the beginning of the string.$int_width − The width of the desired trim. Negative widths count from the ... Read More

PHP – mb_split (Multibyte Split) function

Urmila Samariya
Updated on 11-Oct-2021 13:28:38

310 Views

The mb_split() function in PHP is used to split a multibyte string using regular expressions. It returns the results in an array format.Syntaxarray mb_split($str_pattern, $str_string, int $limit=-1)Parametersmb_split() accepts the following three parameters −$str_pattern − It is used for the regular expression's pattern.$str_string − It is used to split the string.$limit − It is an optional parameter that is used to specify the limit elements.Return ValuesThe mb_split function will return the split elements result as an array. Or, it will return False on failure.Example 1OutputIt will produce the following output −Array ( [0] => Welcome ... Read More

PHP – mb_preferred_mime_name() function

Urmila Samariya
Updated on 11-Oct-2021 13:26:57

53 Views

The mb_preferred_mime_name() function in PHP is used to return the MIME string for the character encoding and it returns the charset string. It gets a MIME (Multipurpose Internet Mail Extensions) charset string for the specific encoding.Syntaxstring mb_preferred_mime_name($string_encoding)Parametersmb_preferred_mime_name() accepts only one parameter −$string_encoding − This parameter is used to check the encoding.Return ValuesThe mb_preferred_mime_name() function returns the MIME charset string for the charset encoding. It returns False if no charset is preferred for the given encoding.ExampleLet us now take an example and see how it works −OutputIt will produce the following output −EUC-JP Read More

PHP – Parse the GET, POST, and COOKIE data using mb_parse_str()

Urmila Samariya
Updated on 11-Oct-2021 13:25:16

498 Views

The mb_parse_str() function in PHP is used to parse the GET, POST, and COOKIE data and it sets the global variable. It parses the URL encoded data and detects the encoding. After that, it converts the coding in the internal encoding and sets values for the global variables. This function is supported in PHP 7 or higher versions.Syntaxstring mb_parse_str($str_string, $array_result)Parametersmb_parse_str() accepts the following two parameters −$str_string − This parameter is used for the URL encoded data.$result − The result parameter will be an array holding the decrypted and character encrypted converted values.Return ValuesThe mb_parse_str() function returns True on success or ... Read More

PHP – How to get the Unicode point value of a given character?

Urmila Samariya
Updated on 11-Oct-2021 13:22:14

2K+ Views

In PHP, we can use the mb_ord() function to get the Unicode code point value of a given character. This function is supported in PHP 7 or higher versions. The mb_ord() function complements the mc_chr() function.Syntaxint mb_ord($str_string, $str_encoding)Parametersmb_ord() accepts the following two parameters −$str_string − This parameter is used for the string.$str_encoding − This is the character encoding parameter. If it is absent or NULL, then we can use the internal encoding value.Return Valuesmb_ord() returns the Unicode point value for the first character from the given string. It will return False on failure.ExampleOutputIt will produce the following output −Get the ... Read More

PHP – Get or set the HTTP output character encoding with mb_http_output()

Urmila Samariya
Updated on 11-Oct-2021 13:11:03

276 Views

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.Syntaxstring|bool mb_http_output(str $encoding = null)Parametersmb_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.Return ValuesIf the encoding is omitted, then the mb_http_output() function will return the current HTTP output character encoding. Otherwise, it returns True on success and False on ... Read More

Advertisements