PHP – mb_eregi() function

PHPServer Side ProgrammingProgramming

The mb_eregi (multibyte regular expression ignore) function in PHP is used to ignore the regular expression match with multibyte support. This function performs the case-insensitive regular expression match with the multibyte support.

Syntax

bool mb_eregi(
   $str_ pattern,
   $str_string,
   $arr_matches=null
)

For example

(pattern = "or", string = "Hello World");

Parameters

mb_eregi() accepts the following three parameters −

  • pattern − This parameter matches the pattern in the given string.

mb_ereg ("or", "Hello World")
// "or" is the pattern that will be matched
// in the given string "Hello World".
  • string − This parameter is used to search the string.

  • matches − The matches parameter is called after finding the substring of the pattern from another given string. The matches are stored in the elements of the array matches. If the matches are not found, then it returns an empty array.

Return Values

It will check whether the pattern is matched in the string or not. If a pattern is matched, then it returns the integer value "1".

Example

<?php
   //UTF-8 encoding
   $encoding = mb_regex_encoding("UTF-8");

   //String pattern is "or" and
   //string Hello World is used
   $integer = mb_ereg ("or","Hello World");

   //Output
   var_dump($encoding);
   print_r($integer);
?>

Output

bool(true)
1
raja
Published on 11-Oct-2021 13:47:45
Advertisements