Sure! Here's the PHP code to check if the variable $text
contains any of the values 11, 22, 33, 44, 55, or 66. If it does, it will execute other code. If it doesn't, it will break out of the loop.
<?php
$text = "This is a sample text containing 11 and 77";
$keywords = array(11, 22, 33, 44, 55, 66);
foreach ($keywords as $keyword) {
if (strpos($text, strval($keyword)) !== false) {
// Execute other code here if $text contains the keyword
echo "Found keyword: " . $keyword . "\n";
// ...
} else {
// Break out of the loop if $text does not contain the keyword
break;
}
}
?>
In this example, the variable $text
contains the sample text "This is a sample text containing 11 and 77". The code checks if any of the keywords 11, 22, 33, 44, 55, or 66 are present in the text using the strpos()
function. If a keyword is found, you can replace the echo
statement with your desired code to be executed. If none of the keywords are found, the loop will break and exit.