How to check if array exists in an array with PHP

1 Answer

0 votes
// bool in_array ( mixed $needle , array $haystack [, bool $strict = FALSE ] )

$a = array(array('c', 'd'), array('o', 'x'), 'y');

if (in_array(array('c', 'd'), $a)) 
    echo "'c,d' array exist <br />";


if (in_array(array('o', 'x'), $a)) 
    echo "'o,x' array exist <br />";


if (in_array('y', $a)) 
    echo "'y' string exist <br />";


/*
run:

'c,d' array exist 
'o,x' array exist 
'y' string exist 

*/

 



answered Jun 29, 2016 by avibootz

Related questions

1 answer 139 views
2 answers 270 views
2 answers 261 views
6 answers 544 views
1 answer 200 views
2 answers 437 views
437 views asked Jun 17, 2014 by avibootz
...