How to use the count_chars function with mod 0 (count frequency of string character) with PHP

1 Answer

0 votes
$string = "PHP Programming Language";
$result = count_chars($string, 0);

echo "Mode 0 – All character counts:\n";
foreach ($result as $ascii => $count) {
    if ($count != 0)
        echo "ASCII $ascii (" . chr($ascii) . "): $count\n";
}

        
 
/*
run:
             
Mode 0 – All character counts:
ASCII 32 ( ): 2
ASCII 72 (H): 1
ASCII 76 (L): 1
ASCII 80 (P): 3
ASCII 97 (a): 3
ASCII 101 (e): 1
ASCII 103 (g): 4
ASCII 105 (i): 1
ASCII 109 (m): 2
ASCII 110 (n): 2
ASCII 111 (o): 1
ASCII 114 (r): 2
ASCII 117 (u): 1
      
*/

 



answered Mar 5 by avibootz
...