0

I am checking whether two arrays are identical and even though I know they are, my conditional returns false.

Here are the two arrays: http://pastebin.com/knekiW67

Here is the code:

$stored_items = (Array1 in Pastebin link)
$new_items = (Array2 in Pastebin link)

if($stored_items === $new_items) {
    return true;
} else {
    return false;
}

I've even checked the two arrays using https://www.diffchecker.com/ and it responds that they are identical.

Does anyone know why it's returning false?

1
  • I actually ended up using serialize() on the two arrays before comparing them which worked. Commented Nov 1, 2016 at 10:27

1 Answer 1

0

=== if not working for array(only string and int)

for checking array need use http://php.net/manual/ru/function.array-diff-ukey.php with special callback

Sign up to request clarification or add additional context in comments.

4 Comments

Hi, thanks for the reply. I'm not sure I understand what you mean?
Hey, === operator not working for array
His arrays are nested several levels deep. array_diff doesn't recurse.
Please link to English documentation, not Russian.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.