Hello, Is there shorter, more efficient way of doing this type of thing? if (eregi('text1', $checkSite) || eregi('text2', $checkSite) || eregi('text3', $checkSite) || ... ) {... As you can see it will be searching for specific pieces of text from a specified website URL ($checkSite). The code format above works but is there a way of finding multiple pieces of text in the site by only using eregi once?
if (preg_match('~(text1|text2|text3|text4)~i', $checkSite)) { // Match } PHP: Try to start using preg_* functions over ereg_*. The preg_* functions are about 6 times faster.
Yes, the i means case-insensitive. And the ~ are the pattern delimiters. instead of ~ you could also use forwad slashes, @ signs, |,.. and a lot others. I suggest you have a look at this. http://www.phpvideotutorials.com/regex/