- function char_in_string($string){
- for($i=0;$i<sizeof($char_array);$i++){
- $no_of_char[$char_array[$i]]=0;
- for($j=0;$j<sizeof($char_array);$j++){
- if($char_array[$i]==$char_array[$j])
- {
- $no_of_char[$char_array[$i]]++;
- }
- }
- }
- return $no_of_char;
- }
Now show its structure using var_dump()
var_dump(char_in_string("Hello Ahmad Asjad"));
Its result will look something like this.
array (size=12) 'H' => int 1 'e' => int 1 'l' => int 2 'o' => int 1 ' ' => int 2 'A' => int 2 'h' => int 1 'm' => int 1 'a' => int 2 'd' => int 2 's' => int 1 'j' => int 1