What are some potential pitfalls when using strpos in PHP to search for multiple strings in a log file?

One potential pitfall when using strpos in PHP to search for multiple strings in a log file is that it only searches for the first occurrence of each string. To overcome this limitation, you can create a loop to search for each string individually.

$log_file = file_get_contents('example.log');
$search_strings = ['error', 'warning', 'info'];
foreach ($search_strings as $search) {
    if (strpos($log_file, $search) !== false) {
        echo "Found '$search' in log file.\n";
    } else {
        echo "Did not find '$search' in log file.\n";
    }
}