Answers for "count_chars function in php"

PHP
5

how to count string characters in php

<?php
$str1 = 'Hello world!';
echo strlen($str1); // Outputs: 12
Posted by: Guest on June-27-2021
0

count_chars (PHP 4, PHP 5, PHP 7, PHP 8) count_chars — Return information about characters used in a string

<?php
$data = "Two Ts and one F.";

foreach (count_chars($data, 1) as $i => $val) {
   echo "There were $val instance(s) of \"" , chr($i) , "\" in the string.\n";
}
?>
Posted by: Guest on May-14-2022

Browse Popular Code Answers by Language