Answers for "check array value"

PHP
22

check if array has value php

$myArr = [38, 18, 10, 7, "15"];

echo in_array(10, $myArr); // TRUE
echo in_array(19, $myArr); // TRUE

// Without strict check
echo in_array("18", $myArr); // TRUE
// With strict check
echo in_array("18", $myArr, true); // FALSE
Posted by: Guest on January-21-2020
9

value is array

var colors=["red","green","blue"];

if(Array.isArray(colors)){
    //colors is an array
}
Posted by: Guest on July-22-2019

Browse Popular Code Answers by Language