Here is a very short script that I wrote in PHP that will count the number of Capital and Small letter in a given string. The code is very simple to use and understand.
Add me at Facebook my address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com.
Add me at Facebook my address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com.
My mobile number here in the Philippines is 09173084360.
Program Listing
<?php
function CountCaps($string) {
return strlen(preg_replace('/[^A-Z]+/', '', $string));
}
function CountSmall($string) {
return strlen(preg_replace('/[^a-z]+/', '', $string));
}
$str = 'WeLcoMe HOme';
$result1 = CountCaps($str);
$result2 = CountSmall($str);
echo 'The word is ' .$str;
echo '<br><br>';
echo 'Number of Capital Letters ' .$result1.'.';
echo '<br><br>';
echo 'Number of Capital Letters ' .$result2.'.';
?>
No comments:
Post a Comment