In what scenarios would using strpos() be preferable over preg_match_all() in PHP for string manipulation tasks?

strpos() would be preferable over preg_match_all() in PHP for string manipulation tasks when you only need to find the position of the first occurrence of a substring within a string. strpos() is faster and more efficient for simple substring searches compared to regular expressions used in preg_match_all().

// Example of using strpos() to find the position of a substring in a string
$string = "Hello, World!";
$substring = "World";
$position = strpos($string, $substring);

if ($position !== false) {
    echo "The substring '$substring' was found at position $position in the string.";
} else {
    echo "The substring '$substring' was not found in the string.";
}