Answers for "for 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
2

in array php

// Syntax:
in_array ( mixed $needle , array $haystack , bool $strict = false ) : bool

// Example:
$fruits = array('apple', 'banana', 'orange');
in_array('apple', $fruits); // true
in_array('mango', $fruits); // false
Posted by: Guest on February-22-2021

Browse Popular Code Answers by Language