How can multiple values be checked within a string variable using PHP functions like strpos() or strstr()?

To check for multiple values within a string variable using PHP functions like strpos() or strstr(), you can iterate over an array of values and check each one individually. This can be done by using a loop to check each value against the string variable using the strpos() or strstr() functions. If any of the values are found within the string, you can perform the desired actions accordingly.

$string = "This is a sample string to check";
$values = array("sample", "check");

foreach ($values as $value) {
    if (strpos($string, $value) !== false) {
        echo "Value '$value' found in the string.\n";
    } else {
        echo "Value '$value' not found in the string.\n";
    }
}