PHP array_diff weirdness
<p>This is such a simple problem but the PHP doc does not explain why it is happening.</p>

<p>I have this code:</p>

<pre><code>var_dump($newattributes); var_dump($oldattributes);
var_dump(array_diff($newattributes, $oldattributes));
</code></pre>

<p>For briefity I am going to omit large parts of the structure I am actually using (since each is 117 elements long) and cut to the case.</p>

<p>I have one array called <code>$newattributes</code> which looks like:</p>

<pre><code>array(117){
    // Lots of other attributes here
    ["deleted"] =&gt; int(1)
}
</code></pre>

<p>And another called <code>$oldattributes</code> which looks like:</p>

<pre><code>array(117){
    // Lots of other attributes here
    ["deleted"] =&gt; string(1) "0"
}
</code></pre>

<p>Which looks different right? According to <code>array_diff</code>: no. The output I get from <code>array_diff</code> is:</p>

<pre><code>array(0) { } 
</code></pre>

<p>I have read the documentation page however it says:</p>

<blockquote>
  <p>Two elements are considered equal if and only if (string) $elem1 ===
  (string) $elem2. In words: when the string representation is the same.</p>
</blockquote>

<p>And I am not sure how "1" can object equal "0".</p>

<p>So am I seeing some caveat with <code>array_diff</code> I didn't take into consideration?</p>
