Copyright ©

PHP Function eregi()



int eregi(string pattern, string string, [array regs]);

Definition and Usage

The eregi() function searches throughout a string specified by pattern for a string specified by string. The search is not case sensitive. Eregi() can be particularly useful when checking the validity of strings, such as passwords.

The optional input parameter regs contains an array of all matched expressions that were grouped by parentheses in the regular expression.

Return Value


Following is the piece of code, copy and paste this code into a file and verify the result.


$password = "abc";
if (! eregi ("[[:alnum:]]{8,10}", $password))
   print "Invalid password! Passwords must be from 8 - 10 chars";
  print "Valid password";

This will produce following result

Invalid password! Passwords must be from 8 - 10 chars


Copyright ©