PHP UPPERCASE DETECT AND BLOCK, SCRIPT TO DETECT UP LETTERS IN TEXT FORMS AND CALCULATE THE PERCENT
Sometimes users tend to use capital ( UP) letters in interactive forms. This may be due to the fact that they want to make himself comments or activity more visible or due to a lack of experience online. To prevent such things will present a nice little php script that can detect and block using exces of uppercase (up letter ) in a text input ( eg. form html )
The php script
=========
<?php
$analized_string = "How many UPPER Letters are IN ThIS String";
$maximum_percent_allowed='34';//you can cange this percent with your own
preg_match_all('/[A-Z]/', $analized_string, $match) ;
$total_upper_case_count = count($match [0]);
echo "Total Upper Case Count = " . $total_upper_case_count."<br>";
$total_characters= strlen($analized_string);
$up_leters_percent=ceil(($total_upper_case_count*100)/$total_characters);
echo "Percent of Upper Case = " . $up_leters_percent. "%";
if ($up_leters_percent>$maximum_percent_allowed)
{
echo'<br>You used too many up letters';exit;
}
?>
==============
Output (in this case ):
Total Upper Case Count = 13
Percent of Upper Case = 32%