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 Link to comment https://forums.phpfreaks.com/topic/89736-solved-preg_match-best-way-to-do-multiple-times/ 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 Link to comment https://forums.phpfreaks.com/topic/89736-solved-preg_match-best-way-to-do-multiple-times/#findComment-459833 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 Link to comment https://forums.phpfreaks.com/topic/89736-solved-preg_match-best-way-to-do-multiple-times/#findComment-459843 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.