Saturday, 7 September 2013

PHP - Find the Position of a Word in a String?

PHP - Find the Position of a Word in a String?

Is there a function that allows me to find the position of a word in a
string? By position I don't mean which number char it is in a string. I
know there are plenty of functions that do this already such as strpos()
and strstr() and others. What I'm looking for is a function that will
return the number a word is in string relative to the number of words.
So for example, if I'm searching for "string" in the text "This is a
string" the result would be 4.

No comments:

Post a Comment