note 48327 deleted from function.count-chars by tularis

From: Date: Mon, 27 Dec 2004 19:58:01 +0000
Subject: note 48327 deleted from function.count-chars by tularis
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-82360@lists.php.net to get a copy of this message
Note Submitter: Wouter W ---- <?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"); } ?>

« previous php.notes (#82360) next »