Answers for "how to check the value using array php"

PHP
41

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
1

php array check

<?php
$a = "Hello";
echo "a is " . is_array($a) . "<br>";

$b = array("red", "green", "blue");
echo "b is " . is_array($b) . "<br>";

$c = array("Peter"=>"35", "Ben"=>"37", "Joe"=>"43");
echo "c is " . is_array($c) . "<br>";

$d = "red, green, blue";
echo "d is " . is_array($d) . "<br>";
?>
Posted by: Guest on April-19-2022

Code answers related to "how to check the value using array php"

Browse Popular Code Answers by Language