Image that there could be a string
fred
Fred
FRED
First of all I need to know that these are same which I can do with
strtolower, but how could I tell
that 'FRED' is 'most captilised?
Iterate through the string and count the number of capitalised letters.
You can do something like this (untested pseudocode)
$myStr = "Fred";
$numOfCapLetters = 0;
$curLetter = '';
for( $i = 0; $i <= strlen( $myStr ); $i++ ) {
$curLetter = $myStr{$i};
if( strtoupper( $curLetter ) == $curLetter ) {
$numOfCapLetters++;
}
}
then just compare the $numOfCapLetters for each string.
thnx,
Chris
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php