Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

39,895 questions

51,826 answers

573 users

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 125 views
2 answers 251 views
2 answers 233 views
6 answers 488 views
1 answer 183 views
2 answers 418 views
418 views asked Jun 17, 2014 by avibootz
...