Jump to content

number of a string frequency ?


Recommended Posts

hello everybody if I have this :

$st = 'the peace must cover all over the world';

and :

$e= 'e';

how can i detect the number of frequency (or occurrence) of the letter 'e' ???I used stripos() , strpos(), strrchr() ...etc but it find first and last occurrence of a string and not number of the occurrence!!!!!!!!!!!

Link to comment
Share on other sites

Here's a tip:The online PHP manual is really remarkable documentation. One of its best features is the column on the left that lists all the functions that are related to the one you're reading about (because they apply to the same data type).Every time you read about a function is an opportunity to glance over there and get familiar with the kind of stuff that's available. You don't even have to consciously memorize the list. After a hundred lookups or so, parts of the list will just stick in your mind.But only if you get in the habit of looking.

Edited by Deirdre's Dad
Link to comment
Share on other sites

Here's a tip:...But only if you get in the habit of looking.
hear, hear !!
thanks so much that what I'm looking for .. :)
also have a look at preg_match(), it's a more powerful method i think.i actually discovered that first before strpos() and it's more "advanced", but strpos() is what was more suited to my requirements, and the manual even told me so !
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...