PHP Check Element in Array
To check an element in an array, you can use the
in_array function.
Let the following array be given:
<?php
$arr = ['a', 'b', 'c'];
?>
Let's check using in_array
if the element 'b' is in this array:
<?php
$arr = ['a', 'b', 'c'];
$elem = in_array('b', $arr);
var_dump($elem);
?>
Code execution result:
true