PHP in_array question when comparing 2 arrays...

Posted on 2009-02-15
Last Modified: 2012-05-06
I'm doing PHP in_array as such:

in_array(Array ( [0] => 38 [1] => 40 ) ,Array ( [0] => 38 [1] => 39 [2] => 40 ) )

but it never returns true, even though according to the docs it should...

What am I doing wrong, and anyway to make it work? I'm comparing a bunch of arrays...
Question by:interclubs
    1 Comment

    Accepted Solution

    Got it to work:

    if(count(array_intersect($Array1,$Array2)) == count($Array1))  { echo 'yes';}

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Threat Intelligence Starter Resources

    Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

    Consider the following scenario: You are working on a website and make something great - something that lets the server work with information submitted by your users. This could be anything, from a simple guestbook to a e-Money solution. But what…
    Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
    Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
    The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    8 Experts available now in Live!

    Get 1:1 Help Now