<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/ref.array.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'en',
  ),
  'this' => 
  array (
    0 => 'function.array-diff-assoc.php',
    1 => 'array_diff_assoc',
    2 => 'Computes the difference of arrays with additional index check',
  ),
  'up' => 
  array (
    0 => 'ref.array.php',
    1 => 'Array Functions',
  ),
  'prev' => 
  array (
    0 => 'function.array-diff.php',
    1 => 'array_diff',
  ),
  'next' => 
  array (
    0 => 'function.array-diff-key.php',
    1 => 'array_diff_key',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/array/functions/array-diff-assoc.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.array-diff-assoc" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">array_diff_assoc</h1>
  <p class="verinfo">(PHP 4 &gt;= 4.3.0, PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">array_diff_assoc</span> &mdash; <span class="dc-title">Computes the difference of arrays with additional index check</span></p>

 </div>
 
 <div class="refsect1 description" id="refsect1-function.array-diff-assoc-description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>array_diff_assoc</strong></span>(<span class="methodparam"><span class="type"><a href="language.types.array.php" class="type array">array</a></span> <code class="parameter">$array</code></span>, <span class="methodparam"><span class="type"><a href="language.types.array.php" class="type array">array</a></span> <code class="parameter">...$arrays</code></span>): <span class="type"><a href="language.types.array.php" class="type array">array</a></span></div>

  <p class="para rdfs-comment">
   Compares <code class="parameter">array</code> against <code class="parameter">arrays</code> and
   returns the difference. Unlike <span class="function"><a href="function.array-diff.php" class="function">array_diff()</a></span> the array
   keys are also used in the comparison.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.array-diff-assoc-parameters">
  <h3 class="title">Parameters</h3>
  <p class="para">
   <dl>

    
     <dt><code class="parameter">array</code></dt>
     <dd>
      <p class="para">
       The array to compare from
      </p>
     </dd>
    

    
     <dt><code class="parameter">arrays</code></dt>
     <dd>
      <p class="para">
       Arrays to compare against
      </p>
     </dd>
    

   </dl>
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.array-diff-assoc-returnvalues">
  <h3 class="title">Return Values</h3>
  <p class="para">
   Returns an <span class="type"><a href="language.types.array.php" class="type array">array</a></span> containing all the values from
   <code class="parameter">array</code> that are not present in any of the other arrays.
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-function.array-diff-assoc-changelog">
  <h3 class="title">Changelog</h3>
  <p class="para">
   <table class="doctable informaltable">
    
     <thead>
      <tr>
       <th>Version</th>
       <th>Description</th>
      </tr>

     </thead>

     <tbody class="tbody">
      <tr>
  <td>8.0.0</td>
  <td>
  This function can now be called with only one parameter.
  Formerly, at least two parameters have been required.
  </td>
</tr>

     </tbody>
    
   </table>

  </p>
 </div>




 <div class="refsect1 examples" id="refsect1-function.array-diff-assoc-examples">
  <h3 class="title">Examples</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>Example #1 <span class="function"><strong>array_diff_assoc()</strong></span> example</strong></p>
    <div class="example-contents"><p>
     In this example the <code class="literal">&quot;a&quot; =&gt; &quot;green&quot;</code>
     pair is present in both arrays and thus it is not in the output from the
     function. Unlike this, the pair <code class="literal">0 =&gt; &quot;red&quot;</code>
     is in the output because the key of <code class="literal">&quot;red&quot;</code> is
     automatically assigned to <code class="literal">0</code> in the first array,
     whereas it is assigned to <code class="literal">1</code> in the second array as the
     key <code class="literal">0</code> is already taken by <code class="literal">yellow</code>.
    </p></div>
    <div class="example-contents">
<div class="annotation-interactive phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />$array1 </span><span style="color: #007700">= array(</span><span style="color: #DD0000">"a" </span><span style="color: #007700">=&gt; </span><span style="color: #DD0000">"green"</span><span style="color: #007700">, </span><span style="color: #DD0000">"b" </span><span style="color: #007700">=&gt; </span><span style="color: #DD0000">"brown"</span><span style="color: #007700">, </span><span style="color: #DD0000">"c" </span><span style="color: #007700">=&gt; </span><span style="color: #DD0000">"blue"</span><span style="color: #007700">, </span><span style="color: #DD0000">"red"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$array2 </span><span style="color: #007700">= array(</span><span style="color: #DD0000">"a" </span><span style="color: #007700">=&gt; </span><span style="color: #DD0000">"green"</span><span style="color: #007700">, </span><span style="color: #DD0000">"yellow"</span><span style="color: #007700">, </span><span style="color: #DD0000">"red"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$result </span><span style="color: #007700">= </span><span style="color: #0000BB">array_diff_assoc</span><span style="color: #007700">(</span><span style="color: #0000BB">$array1</span><span style="color: #007700">, </span><span style="color: #0000BB">$array2</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">print_r</span><span style="color: #007700">(</span><span style="color: #0000BB">$result</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

    <div class="example-contents"><p>The above example will output:</p></div>
    <div class="example-contents screen">
<div class="annotation-interactive examplescode"><pre class="examplescode">Array
(
    [b] =&gt; brown
    [c] =&gt; blue
    [0] =&gt; red
)</pre>
</div>
    </div>
   </div>
  </p>
  <p class="para">
   <div class="example" id="example-2">
    <p><strong>Example #2 <span class="function"><strong>array_diff_assoc()</strong></span> example</strong></p>
    <div class="example-contents"><p>
     Two values from <em>key =&gt; value</em> pairs are
     considered equal only if <code class="literal">(string) $elem1 === (string)
     $elem2 </code>. In other words a strict check takes place so
     the string representations must be the same.
    </p></div>
    <div class="example-contents">
<div class="annotation-interactive phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />$array1 </span><span style="color: #007700">= array(</span><span style="color: #0000BB">0</span><span style="color: #007700">, </span><span style="color: #0000BB">1</span><span style="color: #007700">, </span><span style="color: #0000BB">2</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$array2 </span><span style="color: #007700">= array(</span><span style="color: #DD0000">"00"</span><span style="color: #007700">, </span><span style="color: #DD0000">"01"</span><span style="color: #007700">, </span><span style="color: #DD0000">"2"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$result </span><span style="color: #007700">= </span><span style="color: #0000BB">array_diff_assoc</span><span style="color: #007700">(</span><span style="color: #0000BB">$array1</span><span style="color: #007700">, </span><span style="color: #0000BB">$array2</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">print_r</span><span style="color: #007700">(</span><span style="color: #0000BB">$result</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

    <div class="example-contents"><p>The above example will output:</p></div>
    <div class="example-contents screen">
<div class="annotation-interactive examplescode"><pre class="examplescode">Array
(
    [0] =&gt; 0
    [1] =&gt; 1
)</pre>
</div>
    </div>
   </div>
  </p>
 </div>


 <div class="refsect1 notes" id="refsect1-function.array-diff-assoc-notes">
  <h3 class="title">Notes</h3>
  <blockquote class="note"><p><strong class="note">Note</strong>: 
   <span class="simpara">
    This function only checks one dimension of an n-dimensional
    array. It is possible to check deeper dimensions by using, for example,
    <code class="literal">array_diff_assoc($array1[0], $array2[0]);</code>.
   </span>
  </p></blockquote>
  <blockquote class="note"><p><strong class="note">Note</strong>: 
   <span class="simpara">
    Ensure arguments are passed in the correct order when comparing similar
    arrays with more keys. The new array should be the first in the list.
   </span>
  </p></blockquote>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.array-diff-assoc-seealso">
  <h3 class="title">See Also</h3>
  <p class="para">
   <ul class="simplelist">
    <li><span class="function"><a href="function.array-diff.php" class="function" rel="rdfs-seeAlso">array_diff()</a> - Computes the difference of arrays</span></li>
    <li><span class="function"><a href="function.array-diff-uassoc.php" class="function" rel="rdfs-seeAlso">array_diff_uassoc()</a> - Computes the difference of arrays with additional index check which is performed by a user supplied callback function</span></li>
    <li><span class="function"><a href="function.array-udiff-assoc.php" class="function" rel="rdfs-seeAlso">array_udiff_assoc()</a> - Computes the difference of arrays with additional index check, compares data by a callback function</span></li>
    <li><span class="function"><a href="function.array-udiff-uassoc.php" class="function" rel="rdfs-seeAlso">array_udiff_uassoc()</a> - Computes the difference of arrays with additional index check, compares data and indexes by a callback function</span></li>
    <li><span class="function"><a href="function.array-intersect.php" class="function" rel="rdfs-seeAlso">array_intersect()</a> - Computes the intersection of arrays</span></li>
    <li><span class="function"><a href="function.array-intersect-assoc.php" class="function" rel="rdfs-seeAlso">array_intersect_assoc()</a> - Computes the intersection of arrays with additional index check</span></li>
   </ul>
  </p>
 </div>


</div><?php manual_footer($setup); ?>