Hello folks! welcome back to a new section of our tutorial on PHP. In this tutorial guide, we will be discussing about the PHP eregi() Function.
The eregi() function searches round a string specified by pattern for a string specified by string. Search with this function is not case sensitive. Eregi() can be particularly useful when checking the validity of strings, such as password.
The optional input parameter regs holds an array of all matched expressions that were grouped by parentheses in the PHP regular expression.
The eregi() function searches round a string specified by pattern for a string specified by string. Search with this function is not case sensitive. Eregi() can be particularly useful when checking the validity of strings, such as password.
The optional input parameter regs holds an array of all matched expressions that were grouped by parentheses in the PHP regular expression.
Syntax
The following is the syntax for the eregi() function -
int eregi(string pattern, string string, [array regs]);
Return Value
- This PHP function returns true if the pattern is validated, otherwise false.
Example
Following is a simple example -
<?php $password = "abc"; if (! eregi ("[[:alnum:]]{8,10}", $password)) { print "Invalid password! Passwords must be from 8 - 10 chars"; } else { print "Valid password"; } ?>
Output
When the above code is executed, it will produce the following result -
Invalid password! Passwords must be from 8 - 10 chars
READ: PHP ereg() Function
Alright guys! This is where we are rounding up for this tutorial post. In our next tutorial guide, we are going to be discussing about the PHP eregi_replace() Function.
Feel free to ask your questions where necessary and we will attend to them as soon as possible. If this tutorial was helpful to you, you can use the share button to share this tutorial.
Follow us on our various social media platforms to stay updated with our latest tutorials. You can also subscribe to our newsletter in order to get our tutorials delivered directly to your emails.
Thanks for reading and bye for now.
Feel free to ask your questions where necessary and we will attend to them as soon as possible. If this tutorial was helpful to you, you can use the share button to share this tutorial.
Follow us on our various social media platforms to stay updated with our latest tutorials. You can also subscribe to our newsletter in order to get our tutorials delivered directly to your emails.
Thanks for reading and bye for now.