daveh33 Posted February 6, 2008 Share Posted February 6, 2008 This function is new to me - I have just found the below tutorial if (preg_match("/php/i", "PHP is the web scripting language of choice.")) { echo "A match was found."; } else { echo "A match was not found."; } To use this example.. Is it possible to search the text for 'language' & 'scripting' as well as 'php'? Or would I just need to copy the code for each search I want to perform? The goal is to write a script which searches a variable for several words & if any of them match, do 1 thing & if not - do another Quote Link to comment Share on other sites More sharing options...
CerealBH Posted February 6, 2008 Share Posted February 6, 2008 think ur looking 4 preg_match_all im not sure if preg_match stops after it finds what its looking for Quote Link to comment Share on other sites More sharing options...
daveh33 Posted February 6, 2008 Author Share Posted February 6, 2008 OK - I see it needs to be in the below format: - preg_match_all ( string pattern, string subject, array &matches [, int flags [, int offset]] ) I really dont understand how the string pattern works I want to search for hello, hi or hey in $var and then use that to complete an if statement for whether it has a found any matches or not if someone can write this code for me it would be much appreicated Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.