note 48327 added to function.count-chars
| From: | WouterW at osu1 dot php dot net | Date: | Sun, 19 Dec 2004 17:27:08 +0000 |
| Subject: | note 48327 added to function.count-chars | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-82051@lists.php.net to get a copy of this message | ||
<?php
/*The (password) string counter posted by martinpulido on
17-Nov-2004 11:54 is not correct. When there is a duplicate character (for example the password =
121212) it only counts 3 array's not 6. This is because the array build up by
"count_chars" is as follows:
(ASCII nr, frequency)
To get the correct number of password characters I came up with this solution:
*/
$password= "yourpw";
$array = (count_chars($password,1));
$num_char=0;
while(list($key,$value) = each($array)){$num_char=$num_char+$value;}
if ($num_char != 6){echo("You'll need a 6 character password");
}else{
echo("You typed 6 characters");
}
?>
----
Manual Page -- http://www.php.net/manual/en/function.count-chars.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+48327
Delete -- http://master.php.net/manage/user-notes.php?action=delete+48327&report=yes
Reason: bad code -- http://master.php.net/manage/user-notes.php?action=delete+48327&report=yes&reason=bad+code
Reason: spam -- http://master.php.net/manage/user-notes.php?action=delete+48327&report=yes&reason=spam
Reason: useless example -- http://master.php.net/manage/user-notes.php?action=delete+48327&report=yes&reason=useless+example
Reason: contains commercial links -- http://master.php.net/manage/user-notes.php?action=delete+48327&report=yes&reason=contains+commercial+links
Reason: useless note -- http://master.php.net/manage/user-notes.php?action=delete+48327&report=yes&reason=useless+note
Reject -- http://master.php.net/manage/user-notes.php?action=reject+48327&report=yes
Search -- http://master.php.net/manage/user-notes.php