Re: Best way to check for some certain text in a string
| From: | Tom Rogers | Date: | Wed, 21 Aug 2002 16:42:41 +0000 |
| Subject: | Re: Best way to check for some certain text in a string | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-113492@lists.php.net to get a copy of this message | ||
Hi,
Wednesday, August 21, 2002, 11:22:36 PM, you wrote:
JJ> I want to find a certain text in a string and i want it to return me a
JJ> boolean.
JJ> What is the best thing to do this?
JJ> a) ereg("search for this", $string); // returns
JJ> int(1) if true, bool(false) if not
b) strpos($nav->>userAgent, "search for this") > 0 // gives me a boolean
JJ> directly
JJ> Any tips of which one I should use?
JJ> /José Jeria
you can do
if(eregi("search for this", $string)) echo 'found';
--
regards,
Tom