View Single Post
  #8 (permalink)  
Old 05-12-2008, 06:49 AM
sureshbabu sureshbabu is offline
D-Web Programmer
 
Join Date: Jul 2007
Location: India
Posts: 98
sureshbabu is on a distinguished road
Send a message via AIM to sureshbabu Send a message via MSN to sureshbabu Send a message via Yahoo to sureshbabu Send a message via Skype™ to sureshbabu
Default Re: PHP String Functions With Examples

The count_chars() function returns how many times an ASCII character occurs within a string and returns the information.

Syntax

count_chars(string,mode)

Example 1

In this example we will use count_char() 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 (e.g. in the example below, the ASCII value for the letter "l" is 108, and it occurs three times):

<?php
$str = "Hello World!";
print_r(count_chars($str,1));
?>

The output of the code above will be:

Array
(
[32] => 1
[33] => 1
[72] => 1
[87] => 1
[100] => 1
[101] => 1
[108] => 3
[111] => 2
[114] => 1
)
__________________
Thanks
Regards
Sureshbabu Harikrishnan
+91 9884320017
Reply With Quote