Cless Posted August 27, 2008 Share Posted August 27, 2008 Hello. Is there any PHP command similar to the "LIKE" clause within SQL? Typically, the LIKE clause finds out whether or not a piece of a string is located within a specified field in SQL. Basically, in SQL, you can do this: <?PHP //Find Rows $result= mysql_query("SELECT * FROM users WHERE username LIKE '%pie%'"); $rows= mysql_fetch_array($result); ?> That above would search for anybody with the word "pie" within their username. Is there a way to do something similar to that with PHP? For example... <?PHP //Define Variables $moo="blahmooblah"; //If Moo Is Found Within The Variable "Moo" if($moo LIKE "%moo%") { } ?> Obviously, that is not a practical scenario of what would occur.. Anyway, I know using "if($moo LIKE "%moo%")" will not work; which is what I am asking about. Sorry if this is explained vaguely... I was not sure how to explain it. Thanks! Link to comment https://forums.phpfreaks.com/topic/121517-solved-is-there-a-command-similar-to-quotlikequot-within-php/ Share on other sites More sharing options...
slapdashgrim Posted August 27, 2008 Share Posted August 27, 2008 its not so much a function but a technique but here it is its called Regular Expressions read up on it. i think thats what you want Link to comment https://forums.phpfreaks.com/topic/121517-solved-is-there-a-command-similar-to-quotlikequot-within-php/#findComment-626666 Share on other sites More sharing options...
Ken2k7 Posted August 27, 2008 Share Posted August 27, 2008 <?php //Define Variables $moo="blahmooblah"; //If Moo Is Found Within The Variable "Moo" if(strpos($moo, "moo") !== false) { } ?> Link to comment https://forums.phpfreaks.com/topic/121517-solved-is-there-a-command-similar-to-quotlikequot-within-php/#findComment-626667 Share on other sites More sharing options...
Cless Posted August 27, 2008 Author Share Posted August 27, 2008 Thanks! Link to comment https://forums.phpfreaks.com/topic/121517-solved-is-there-a-command-similar-to-quotlikequot-within-php/#findComment-626669 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.