tags:

views:

29

answers:

3

Hi

How can I search a paragraph for one or more sentences using PHP ?

Thank you

+2  A: 

Yes. strpos will tell you whether a string exists within a string.

deceze
Well it'll tell you the first occurrence :P `strstr()` will give you a Boolean return, except I hear it is slower.
alex
@alex `strstr` will return the part of the string starting at the match or `false`. `strpos` will return the starting index or `false`. You have to compare both to `=== false`. Not a big difference, really. :P
deceze
@deceze I should really read the docs before I say something... you're right :) Have a +1
alex
+1  A: 

Have a look over here, maybe here and here.

phimuemue
+1  A: 

Well, you'll probably want to use "preg_match()" if possible (requires knowledge of regular expressions though). "strstr()" works too if you know exactly what you want to find.

NightKev