how to find the number of occurrances of a string?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
jasongr
Forum Contributor
Posts: 206
Joined: Tue Jul 27, 2004 6:19 am

how to find the number of occurrances of a string?

Post by jasongr »

Hello

I have some very long text
I need to count the number of times the phrase 'Num photos'
appears in the global text (stored in variable $content)

Is there an efficient way to do this without resorting to parsing?

regards
User avatar
n00b Saibot
DevNet Resident
Posts: 1452
Joined: Fri Dec 24, 2004 2:59 am
Location: Lucknow, UP, India
Contact:

Post by n00b Saibot »

try substr_count() for your problem...
jasongr
Forum Contributor
Posts: 206
Joined: Tue Jul 27, 2004 6:19 am

Post by jasongr »

thanks for the help n00b Saibot

I am facing a generic parsing problem.
maybe you can help me at viewtopic.php?t=40874
Post Reply