PHP mb_eregi_replace Function

Urmila Samariya
Updated on 11-Oct-2021 13:02:17

266 Views

In PHP, mb_eregi_replace() is used to replace a regular expression with a multibyte support, ignoring case. This function will scan the string for matches to the pattern, then it will replace the matched text with the replacement. This function is supported in PHP 4.2 or higher version.Syntaxstring mb_eregi_replace(str $pattern, str $replacement, str $string, str $options)Parametersmb_eregi_replace() accepts the following four parameters −$pattern − This parameter is used for the regular expression pattern and it may be used multibyte characters. The case will be ignored.$replacement − This parameter is used for text replacement.$string − The string parameter is used to search the ... Read More

PHP mb_ereg_replace Function for Multibyte Regular Expressions

Urmila Samariya
Updated on 11-Oct-2021 12:58:56

743 Views

In PHP, mb_ereg_replace() is used to replace a regular expression with a multibyte support. It scans the string for matches to pattern, then it replaces the matched text with the replacement.Syntaxstring mb_ereg_replace(str $pattern, $str $replacement, str $string, str $options)ParametersThe function accepts the following four parameters −$pattern − This parameter is used for the regular expression pattern. It may use multibyte characters in a pattern.$replacement − This replacement parameter is used to replace the given text.$string − This parameter is used to check the string.$options − This parameter is used to check the search option.Return Valuesmb_ereg_replace() returns success for the resultant ... Read More

PHP mb_ereg_replace_callback Function

Urmila Samariya
Updated on 11-Oct-2021 12:56:47

209 Views

In PHP, mb_ereg_replace_callback() function is used to perform a regular expression search and replace it with a multibyte support using a callback. It will scan the strings and match them with a pattern, then it will replace the matched text with the output of the callback function. This function is like the mb_ereg_replace() function. It is supported in PHP 5.4 or higher version.Syntaxstring mb_ereg_replace_callback(str $pattern, callback $callback, str $string, str $options)ParametersThe function accepts the following four parameters −$pattern − This parameter is used for the regular expression pattern. It may use multibyte characters in a pattern.$callback − This parameter will ... Read More

Match Regular Expression Using mb_ereg_match in PHP

Urmila Samariya
Updated on 11-Oct-2021 12:53:09

498 Views

In PHP, 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 of the string and it is not necessary that it will match the string till the end. This function will return true or 1 if a match is found, else it will return False or 0.Syntaxbool mb_ereg_match(str $pattern, str $string, str $options)ParametersIt accepts the following three parameters −$pattern − This parameter is used for the regular expression.$string − This parameter is being evaluated.$options − It is used for the search.Return Valuesmb_ereg_match() returns true or 1 ... Read More

Get Aliases of a Known Encoding Type Using mb_encoding_aliases in PHP

Urmila Samariya
Updated on 11-Oct-2021 12:49:47

216 Views

In PHP, mb_encoding_aliases() is used to get the aliases of a known encoding type. This function is supported in PHP 5 or higher version.Syntaxarray mb_encoding_aliases(str $encoding)ParametersIt accepts only one parameter, $encoding, which is the encoding type checked for aliases.Return ValuesIt returns a numerically indexed array of encoding aliases on success or it returns False on failure.Errors/ExceptionsIf the encoding is not known, then it gives an E_WARNING level error.Example 1OutputArray ( [0] => ANSI_X3.4-1968 [1] => iso-ir-6 [2] => ANSI_X3.4-1986 [3] => ISO_646.irv:1991 [4] => US-ASCII ... Read More

Encode String for MIME Header using mb_encode_mimeheader in PHP

Urmila Samariya
Updated on 11-Oct-2021 12:43:16

617 Views

In PHP, mb_encode_mimeheader() function is used to encode a string for MIME (Multipurpose Internet Mail Extensions) header. It encodes a given string by the MIME header encoding scheme.Syntaxstring mb_encode_mimeheader(str $string, str $charset, str $transfer_encoding, str $newLine, int $indent)ParametersThe mb_encode_mimeheader() function accepts five parameters −$string − This parameter is used to encode the string. Its encoding should be the same as mb_internal_encoding()$charset − This parameter specifies the character set name in which the string is represented.$transfer_encoding − This parameter specifies the scheme of MIME encoding. It should be base64 (B) or Quoted-printable (Q). If not given, then it falls back to ... Read More

Calculate Earnings from Selling Shoes in Python

Arnab Chakraborty
Updated on 11-Oct-2021 12:40:03

444 Views

Suppose in a shoe shop there are n different shoe with different sizes present in an array called size and another list of pairs for m customers called demand is given, where demand[i] contains (shoe_size, money) so a customer with demand i has a demand of shoe whose size is shoe_size and he/she can pay given amount of money. We have to find how much money the shopkeeper can earn by selling these shoes.So, if the input is like shoes = [2, 3, 4, 5, 6, 8, 7, 6, 5, 18] demand = [(6, 55), (6, 45), (6, 55), (4, ... Read More

Find Cartesian Product of Two Lists in Python

Arnab Chakraborty
Updated on 11-Oct-2021 12:35:53

6K+ Views

Suppose we have two list of data l1 and l2. We have to find Cartesian product of these two lists. As we know if two lists are like (a, b) and (c, d) then the Cartesian product will be {(a, c), (a, d), (b, c), (b, d)}. To do this we shall use itertools library and use the product() function present in this library. The returned value of this function is an iterator. We have to convert it into list by passing the output into list() constructor.So, if the input is like l1 = [1, 5, 6] l2 = [1, ... Read More

Print Rangoli Pattern Using Alphabets in Python

Arnab Chakraborty
Updated on 11-Oct-2021 12:26:42

5K+ Views

Suppose we have a number n. We have to create alphabet rangoli of n x n size. n must be within 1 and 26 and it will start from a and end at z when n is 26.So, if the input is like 5, then the output will be--------e-------- ------e-d-e------ ----e-d-c-d-e---- --e-d-c-b-c-d-e-- e-d-c-b-a-b-c-d-e --e-d-c-b-c-d-e-- ----e-d-c-d-e---- ------e-d-e------ --------e--------To solve this, we will follow these steps −for i in range n-1 to 0, decrease by 1, dofor j in range 0 to i-1, doprint "--"for j in range n-1 to i+1, decrease by 1, doprint character whose ASCII is j+97 and print ... Read More

Detect Character Encoding Using mb_detect_encoding in PHP

Urmila Samariya
Updated on 11-Oct-2021 12:19:32

7K+ Views

In PHP, mb_detect_encoding() is used to detect the character encoding. It can detect the character encoding for a string from an ordered list of candidates. This function is supported in PHP 4.0.6 or higher version.mb_detect_encoding() is useful with multibyte encoding, where not all sequences of bytes form a valid string. If the input string contains such type of a sequence, then that encoding will be rejected, and it will check for the next encoding.Syntaxstring mb_detect_encoding(str $string, str $encoding, bool $strcit)Automatic detection of character encoding is not entirely reliable without some additional information. We can say that character encoding detection is ... Read More

Advertisements