michael123199
asked on
counting occurence(s)
I've got 2 variables named $one and $two.
$one contains a whole sentence, for example:
$one="The cat is never far from home";
$two contains some characters, for example:
$two="The e o";
Now I want to count the occurences of each character/word of $two in $one.
For example:
'The' should give as result 1, because the word The occures one time in $one
'e' should give as result 3, because the character 'e' occures three times in $one
'o' should give a result 2, because the character 'o' occures two times in $one
Which lines do I need for this ?
$one contains a whole sentence, for example:
$one="The cat is never far from home";
$two contains some characters, for example:
$two="The e o";
Now I want to count the occurences of each character/word of $two in $one.
For example:
'The' should give as result 1, because the word The occures one time in $one
'e' should give as result 3, because the character 'e' occures three times in $one
'o' should give a result 2, because the character 'o' occures two times in $one
Which lines do I need for this ?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.