note 85257 added to function.strpos

From: Date: Fri, 22 Aug 2008 09:01:46 +0000
Subject: note 85257 added to function.strpos
Groups: php.notes 
Request: Send a blank email to php-notes+get-143739@lists.php.net to get a copy of this message
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 ---- Server IP: 217.174.223.124 Probable Submitter: 195.221.0.6 (proxied: 195.221.11.17) ---- Manual Page -- http://www.php.net/manual/en/function.strpos.php Edit -- https://master.php.net/note/edit/85257 Del: integrated -- https://master.php.net/note/delete/85257/integrated Del: useless -- https://master.php.net/note/delete/85257/useless Del: bad code -- https://master.php.net/note/delete/85257/bad+code Del: spam -- https://master.php.net/note/delete/85257/spam Del: non-english -- https://master.php.net/note/delete/85257/non-english Del: in docs -- https://master.php.net/note/delete/85257/in+docs Del: other reasons-- https://master.php.net/note/delete/85257 Reject -- https://master.php.net/note/reject/85257 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#143739) next »