<?php
foreach(count_chars("This is our test sentence", 1) as $key=>$value)
{
echo("$key: $value\n<br>");
}
?>
foreach(count_chars("This is our test sentence", 1) as $key=>$value)
{
echo("$key: $value\n<br>");
}
?>
count_chars(string,mode)
Parameters Description:
string : Required. Defines the input string.<?php
echo "<strong>here we will use count_chars() with mode 1 to check the string. Mode 1 will return an array with the ASCII value as key and how many times it occurred as value :</strong><br />";
$str_name = "Good Morning!";
print_r(count_chars($str_name,1));
echo "<br /><strong> now we will use the count_chars() with mode 3 to check the string. Mode 3 will return a string with all the different characters used :</strong><br />";
echo count_chars($str_name,3);
?>
here we will use count_chars() with mode 1 to check the string. Mode 1 will return an array with the ASCII value as key and how many times it occurred as value :
Array (
[32] => 1
[33] => 1
[71] => 1
[77] => 1
[100] => 1
[103] => 1
[105] => 1
[110] => 2
[111] => 3
[114] => 1
)
now we will use the count_chars() with mode 3 to check the string. Mode 3 will return a string with all the different characters used :
!GMdginor
Hello Friends! I am Ramana a part time blogger from Hyderabad.