note 49983 added to function.count-chars
| From: | AlexGemmell at osu1 dot php dot net | Date: | Mon, 14 Feb 2005 18:03:42 +0000 |
| Subject: | note 49983 added to function.count-chars | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-85023@lists.php.net to get a copy of this message | ||
Use: Great for checking for unique characters in a password.
I wanted to check that my website users, when registering a user account, chose a "valid"
(not-so-easily-guessed) password.
One of the many checks was that the password must have 6 unique characters. I was tying myself in
knots with all kinds of recursive array calling when I was offered this wonderful one line solution:
function check_password($password) {
#Have 6 unique characters
if (count(count_chars($password, 1)) < 6) return false;
#
# other checks returning false as necessary
#
#
return true;
}
I cannot claim this wonderful line for myself - a Mr Lynch suggested this to me. Thanks!
----
Manual Page -- http://www.php.net/manual/en/function.count-chars.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+49983
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+49983&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+49983&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+49983&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+49983&report=yes&reason=useless
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+49983&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+49983&report=yes
Search -- http://master.php.net/manage/user-notes.php