how would i go about counting the number of characters in a string?

i have tried count but that gives me number of words i think and i looked at char_count or whatever it is but that doesnt give me the number of characters in a string either. just some other crazy info. please help!!!

    $string = 'Count my chars without spaces, please !';
    
    $count_spaces = substr_count($string, ' ');
    $count_chars_altogether = strlen($string);
    $count_chars_without_spaces = $count_chars_altogether-$count_spaces;
    
    echo "This string contains <b>".$count_spaces."</b>&nbsp;spaces.<br />";
    echo "This string contains <b>".$count_chars_altogether."</b>&nbsp;chars altogether.<br />";
    echo "This string contains <b>".$count_chars_without_spaces."</b> chars without spaces !";
    

    output:

    This string contains 6 spaces.
    This string contains 39 chars altogether.
    This string contains 33 chars without spaces !

      Write a Reply...