preg_match("/Designer:(.*?)|Created by:(.*?)n/i",$sitesource,$designer);
Hi, Can anyone tell me how can I perform multiple searches? For example, if the “designer” keyword not found, then search for “created by” and so on
Advertisement
Answer
You can use
preg_match_all("/(?:Created by|Designer):(.*)/i", $sitesource, $designer);
That is, use preg_match_all to match multiple occurrences and merge the two alternatives into a simpler (?:Created by|Designer):(.*) that means
(?:Created by|Designer)– eitherCreated byorDesigner:– a colon(.*)– capturing group #1: the rest of the line.
See the regex demo.