Jump to content

Scanning a page


lihman

Recommended Posts

I need to scan a page for certain words. If the page has those words, then i want to perform a certain action and if not, then a different action. However, I don't need all of the words to be present on the page, just one of them.

 

How would I do that?

 

For example, if the words that I wanted to look for are:

 

Green

Blue

Red

 

and $result contained:

 

The blue cat was big.

 

I want if(preg_match.....

 

to say yes even though red and green weren't present.

 

Would I use preg_match or preg_match_all or something else? I basically need like an 'OR' between the terms I am looking for in $result.

Link to comment
https://forums.phpfreaks.com/topic/201817-scanning-a-page/
Share on other sites

might have to benchmark it and it certainly depends on how big the subject is (and in the end of the day diff might be too small to care...) but in general if you are just wanting to check a string within a string (not looking to match a pattern) the built-in string search functions are faster.  strpos, stripos, strstr or stristr, etc...

Link to comment
https://forums.phpfreaks.com/topic/201817-scanning-a-page/#findComment-1059846
Share on other sites

  • 3 weeks later...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.