In what scenarios would it be more beneficial to use stripos instead of preg_match_all for string searches in PHP?

stripos is more beneficial than preg_match_all for string searches in PHP when you are simply looking for the occurrence of a substring within a larger string, regardless of its position or context. stripos is faster and more efficient for simple substring searches compared to the more complex and resource-intensive preg_match_all, which is better suited for pattern matching with regular expressions.

// Using stripos for simple substring search
$haystack = "Hello, World!";
$needle = "world";

if (stripos($haystack, $needle) !== false) {
    echo "Substring found!";
} else {
    echo "Substring not found.";
}