如何使用PHP在下面提到的段落中找到字母“t”的计数


how to find the count of letter 't' in the below paragraph mentioned using php

$a='Would you like to have responses to your questions sent to you via email'
for($a as $b=>c){
}

请给我解决方案

<?php echo substr_count($a, 't'); ?>

这是一个解决方案,但不一定是最好的

$letterCount = array_count_values(
    str_split(strtolower($a))
);
$tCount = (isset($letterCount['t'])) ? $letterCount['t'] : 0;
$count = preg_match_all('/t/', $str);

检查这个

<?php
$a = 'Would you like to have responses to your questions sent to you via email';
$t_explod = explode('t', strtolower($a));
echo count($t_explod) - 1;
?>