Answers for "value check in array php"

PHP
18

php in array

$colors = array("red", "blue", "green"); 
 
if (in_array("red", $colors)) { 
	echo "found red in array"; 
}
Posted by: Guest on July-01-2019
15

php value in array

in_array ( mixed $needle , array $haystack , bool $strict = false ) : bool
Posted by: Guest on January-28-2021
0

php check if some string contains from array

$string = 'my domain name is website3.com';
foreach ($owned_urls as $url) {
    //if (strstr($string, $url)) { // mine version
    if (strpos($string, $url) !== FALSE) { // Yoshi version
        echo "Match found"; 
        return true;
    }
}
echo "Not found!";
return false;
Posted by: Guest on October-04-2021

Browse Popular Code Answers by Language