I have a string and an array, the array contains all kinds of parts of a string I want to find in the original string (this is for basically reading a error log and identifying what line there is a “Could not find”, or “Error”, etc.)
Is the foreach preg_match the best method?
The easiest and speediest way is using strpos(). If it returns
FALSEit didn’t find the substring, otherwise it did. Make sure you use===as it might return0:For case-insensitivity, use stripos(). If you need more matching power, use preg_match().