Re: high % of capital letters in a string

From: Date: Fri, 07 Jun 2002 03:45:46 +0000
Subject: Re: high % of capital letters in a string
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-101073@lists.php.net to get a copy of this message
/* Perhaps something like this? */ // UNTESTED $string = "ThE sTrInG tO tEsT"; function str2arr($str) { for ( $x = 0 ; $x < ( strlen($str) ) ; $x++ ) { $arr[$x] = substr($str, $x, 1); } return $arr; } foreach ( (str2arr($string)) as $char ) { if ( strtolower($char) != $char ) { $res["cap"]++; } else { $res["low"]++; } } if ( ($res["cap"]/($res["cap"]+$res["low"])) >= ".4" ) { exit("Too many capital letters, LaMeR!"); }

« previous php.general (#101073) next »