<?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-uassoc.php',
    1 => 'array_diff_uassoc',
    2 => 'Computes the difference of arrays with additional index check which is performed by a user supplied callback function',
  ),
  'up' => 
  array (
    0 => 'ref.array.php',
    1 => 'Array Functions',
  ),
  'prev' => 
  array (
    0 => 'function.array-diff-key.php',
    1 => 'array_diff_key',
  ),
  'next' => 
  array (
    0 => 'function.array-diff-ukey.php',
    1 => 'array_diff_ukey',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/array/functions/array-diff-uassoc.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.array-diff-uassoc" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">array_diff_uassoc</h1>
  <p class="verinfo">(PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">array_diff_uassoc</span> &mdash; <span class="dc-title">Computes the difference of arrays with additional index check which is performed by a user supplied callback function</span></p>

 </div>
 
 <div class="refsect1 description" id="refsect1-function.array-diff-uassoc-description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>array_diff_uassoc</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="methodparam"><span class="type"><a href="language.types.callable.php" class="type callable">callable</a></span> <code class="parameter">$key_compare_func</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 used in the comparison.
  </p>
  <p class="para">
   Unlike <span class="function"><a href="function.array-diff-assoc.php" class="function">array_diff_assoc()</a></span> a user supplied callback
   function is used for the indices comparison, not internal function.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.array-diff-uassoc-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>
    

    
     <dt><code class="parameter">key_compare_func</code></dt>
     <dd>
      <p class="para">
 The comparison function must return an integer less than, equal to, or greater than zero if the first argument is considered to be respectively less than, equal to, or greater than the second.
</p>
<div class="methodsynopsis dc-description"><span class="methodname"><span class="replaceable">callback</span></span>(<span class="methodparam"><span class="type"><a href="language.types.mixed.php" class="type mixed">mixed</a></span> <code class="parameter">$a</code></span>, <span class="methodparam"><span class="type"><a href="language.types.mixed.php" class="type mixed">mixed</a></span> <code class="parameter">$b</code></span>): <span class="type"><a href="language.types.integer.php" class="type int">int</a></span></div>

<div class="caution"><strong class="caution">Caution</strong>
 <p class="para">
  Returning <em>non-integer</em> values from the comparison
  function, such as <span class="type"><a href="language.types.float.php" class="type float">float</a></span>, will result in an internal cast to
  <span class="type"><a href="language.types.integer.php" class="type int">int</a></span> of the callback&#039;s return value. So values such as
  <code class="literal">0.99</code> and <code class="literal">0.1</code> will both be cast to an
  integer value of <code class="literal">0</code>, which will compare such values as equal.
 </p>
</div>
     </dd>
    

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


 <div class="refsect1 returnvalues" id="refsect1-function.array-diff-uassoc-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 entries from
   <code class="parameter">array</code> that are not present in any of the other arrays.
  </p>
 </div>




 <div class="refsect1 examples" id="refsect1-function.array-diff-uassoc-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_uassoc()</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 /></span><span style="color: #007700">function </span><span style="color: #0000BB">key_compare_func</span><span style="color: #007700">(</span><span style="color: #0000BB">$a</span><span style="color: #007700">, </span><span style="color: #0000BB">$b</span><span style="color: #007700">)<br />{<br />    return </span><span style="color: #0000BB">$a </span><span style="color: #007700">&lt;=&gt; </span><span style="color: #0000BB">$b</span><span style="color: #007700">;<br />}<br /><br /></span><span style="color: #0000BB">$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_uassoc</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">, </span><span style="color: #DD0000">"key_compare_func"</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 class="example-contents"><p>
     The equality of 2 indices is checked by the user supplied callback function.
    </p></div>
   </div>
  </p>
 </div>
 

 <div class="refsect1 notes" id="refsect1-function.array-diff-uassoc-notes">
  <h3 class="title">Notes</h3>
  <blockquote class="note"><p><strong class="note">Note</strong>: 
   <p class="para">
    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_uassoc($array1[0], $array2[0], &quot;key_compare_func&quot;);</code>.
   </p>
  </p></blockquote>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.array-diff-uassoc-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-assoc.php" class="function" rel="rdfs-seeAlso">array_diff_assoc()</a> - Computes the difference of arrays with additional index check</span></li>
    <li><span class="function"><a href="function.array-udiff.php" class="function" rel="rdfs-seeAlso">array_udiff()</a> - Computes the difference of arrays by using a callback function for data comparison</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>
    <li><span class="function"><a href="function.array-uintersect.php" class="function" rel="rdfs-seeAlso">array_uintersect()</a> - Computes the intersection of arrays, compares data by a callback function</span></li>
    <li><span class="function"><a href="function.array-uintersect-assoc.php" class="function" rel="rdfs-seeAlso">array_uintersect_assoc()</a> - Computes the intersection of arrays with additional index check, compares data by a callback function</span></li>
    <li><span class="function"><a href="function.array-uintersect-uassoc.php" class="function" rel="rdfs-seeAlso">array_uintersect_uassoc()</a> - Computes the intersection of arrays with additional index check, compares data and indexes by separate callback functions</span></li>
   </ul>
  </p>
 </div>


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