Learning PHP
Advanced PHP
PHP Function Reference
PHP Useful Resources
Selected Reading
© 2011 TutorialsPoint.COM
|
PHP Function eregi()
Syntax
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
Example
Following is the piece of code, copy and paste this code into a file and verify the result.
<?php
$password = "abc";
if (! eregi ("[[:alnum:]]{8,10}", $password))
{
print "Invalid password! Passwords must be from 8 - 10 chars";
}
else
{
print "Valid password";
}
?>
|
This will produce following result
Invalid password! Passwords must be from 8 - 10 chars
|
|
|
|