If that works as you want it to (I honestly don't know), I believe this would be more efficient:
$tot_size = 0;
$check_size = count_chars($string, 1);
foreach ($check_size as $value => $frequency) {
$tot_size += ($value * $frequency);
}
echo "Total size in bytes of the string is $tot_size";
I say that for two reasons. First, adding the mode '1' to count_chars makes it only return those values whose frequency is greater than 0, as processing those is a waste of time. Two, a foreach loop will not waste time with the values that do not exist.