I'm still getting 0's for results. Here is my full page of code.
<?
include ('connect.php');
$most = urlencode($most);
echo $most;// for testing
$most = explode(" ", $most);
function countThoseChars($array, $char, $substr=TRUE)
{
$count=0;
if($substr)
{
// We'll use substr_count() method!!
foreach($array as $key=>$val)
{
$num = substr_count($val, $char);
$count = $count+$num;
}
}
else
{
// We'll use count_chars() method!!
foreach($array as $key=>$val)
{
foreach(count_chars($val, 1) as $i=>$num)
{
if(chr($i)==strtolower($char) || chr($i)==strtoupper($char))
{
$count = $count+$num;
}
}
}
}
return $count;
}
$string = array('This is a test of a string', 'And yet another test of another string with some more t\'s in it!');
$T = countThoseChars($most, 't', 0);
$I = countThoseChars($most, 'i', 1);
echo $T.' B\'s and '.$I.' S\'s in the string!';
?>