![]() |
Example: Check Usernames
This is a simple function I made to check if a string is a valid username or not. If it has illegal characters not specified, it'll return false/nothing, and if it's valid it'll return true/1.
PHP Code:
I've never quite understood that function... |
PHP Code:
-m |
Quote:
|
I think that could be further condensed:
PHP Code:
and the 'i' at the end of the expression (after the trailing '/') makes it case insensitive. If you want to enforce a capital at the start of the username just remove the 'i' and change the '[a-z]' to '[A-Z]' or vice-versa To actually strip the chars specified in your function from the string with preg_replace: PHP Code:
|
| All times are GMT. The time now is 02:36 PM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0