To check the key is present in an array or not
<?php
$haystack = array('foo','b','bar');
$target = array('foo', 'bar');
if(count(array_intersect($haystack, $target)) == count($target)){
echo "present";
}else{
echo "not present";
}
?>
<?php
$haystack = array('foo','b','bar');
$target = array('foo', 'bar');
if(count(array_intersect($haystack, $target)) == count($target)){
echo "present";
}else{
echo "not present";
}
?>
Comments
Post a Comment