note 85257 deleted from function.strpos by danbrown

From: Date: Sun, 17 May 2009 16:29:04 +0000
Subject: note 85257 deleted from function.strpos by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-154833@lists.php.net to get a copy of this message
Note Submitter: Wartosh ---- Hi, Chuzasoft Inc : maybe I haven't understood your goal clearly, but I think there is a faster way to determinate whether a pattern is contained in a string (like using the " LIKE '%bla bla%' " in SQL). You should read about "Regular Expression" (powerfull string operations are allowed using it) : http://fr.php.net/manual/en/book.pcre.php Your example, it should be written like this : <? $myString = "Hi, this is good!"; $srchStrg = ".*thi.* goo.*"; $srchRes = preg_match("/$searchThis/", $myString); if ( $searchResult != 0 ) echo "TRUE: string has been found :-)"; else echo "FALSE: string wasn't found :'-("; ?> Sincerely

« previous php.notes (#154833) next »