<?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 => 'it',
  ),
  'this' => 
  array (
    0 => 'function.array-intersect-key.php',
    1 => 'array_intersect_key',
    2 => 'Computes the intersection of arrays using keys for comparison',
  ),
  'up' => 
  array (
    0 => 'ref.array.php',
    1 => 'Array Funzioni',
  ),
  'prev' => 
  array (
    0 => 'function.array-intersect-assoc.php',
    1 => 'array_intersect_assoc',
  ),
  'next' => 
  array (
    0 => 'function.array-intersect-uassoc.php',
    1 => 'array_intersect_uassoc',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/array/functions/array-intersect-key.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.array-intersect-key" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">array_intersect_key</h1>
  <p class="verinfo">(PHP 5 &gt;= 5.1.0, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">array_intersect_key</span> &mdash; <span class="dc-title">Computes the intersection of arrays using keys for comparison</span></p>

 </div>
 
 <div class="refsect1 description" id="refsect1-function.array-intersect-key-description">
  <h3 class="title">Descrizione</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>array_intersect_key</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">
   <span class="function"><strong>array_intersect_key()</strong></span> returns an array
   containing all the entries of <code class="parameter">array</code>
   which have keys that are present in all the arguments.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.array-intersect-key-parameters">
  <h3 class="title">Elenco dei parametri</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">array</code></dt>
     <dd>
      <p class="para">
       The array with master keys to check.
      </p>
     </dd>
    
    
     <dt><code class="parameter">arrays</code></dt>
     <dd>
      <p class="para">
       Arrays to compare keys against.
      </p>
     </dd>
    
   </dl>
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.array-intersect-key-returnvalues">
  <h3 class="title">Valori restituiti</h3>
  <p class="para">
   Returns an associative array containing all the entries of 
   <code class="parameter">array</code> which have keys that are present in all
   arguments.
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-function.array-intersect-key-changelog">
  <h3 class="title">Log delle modifiche</h3>
  <p class="para">
   <table class="doctable informaltable">
    
     <thead>
      <tr>
       <th>Versione</th>
       <th>Descrizione</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-intersect-key-examples">
  <h3 class="title">Esempi</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>Example #1 <span class="function"><strong>array_intersect_key()</strong></span> example</strong></p>
    <div class="example-contents">
<div class="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">'blue'  </span><span style="color: #007700">=&gt; </span><span style="color: #0000BB">1</span><span style="color: #007700">, </span><span style="color: #DD0000">'red'  </span><span style="color: #007700">=&gt; </span><span style="color: #0000BB">2</span><span style="color: #007700">, </span><span style="color: #DD0000">'green'  </span><span style="color: #007700">=&gt; </span><span style="color: #0000BB">3</span><span style="color: #007700">, </span><span style="color: #DD0000">'purple' </span><span style="color: #007700">=&gt; </span><span style="color: #0000BB">4</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$array2 </span><span style="color: #007700">= array(</span><span style="color: #DD0000">'green' </span><span style="color: #007700">=&gt; </span><span style="color: #0000BB">5</span><span style="color: #007700">, </span><span style="color: #DD0000">'blue' </span><span style="color: #007700">=&gt; </span><span style="color: #0000BB">6</span><span style="color: #007700">, </span><span style="color: #DD0000">'yellow' </span><span style="color: #007700">=&gt; </span><span style="color: #0000BB">7</span><span style="color: #007700">, </span><span style="color: #DD0000">'cyan'   </span><span style="color: #007700">=&gt; </span><span style="color: #0000BB">8</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">array_intersect_key</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">?&gt;</span></span></code></div>
    </div>

    <div class="example-contents"><p>Il precedente esempio visualizzerà:</p></div>
    <div class="example-contents screen">
<div class="examplescode"><pre class="examplescode">array(2) {
  [&quot;blue&quot;]=&gt;
  int(1)
  [&quot;green&quot;]=&gt;
  int(3)
}</pre>
</div>
    </div>
   </div>
  </p>
  <p class="para">
   In our example you see that only the keys <code class="literal">&#039;blue&#039;</code>
   and <code class="literal">&#039;green&#039;</code> are present in both arrays and thus
   returned. Also notice that the values for the keys
   <code class="literal">&#039;blue&#039;</code> and <code class="literal">&#039;green&#039;</code> differ between
   the two arrays. A match still occurs because only the keys are checked.
   The values returned are those of <code class="parameter">array</code>.
  </p>
  <p class="para">
   The two keys from the <code class="literal">key =&gt; value</code> pairs are
   considered equal only if
   <code class="literal">(string) $key1 === (string) $key2 </code>. In other words
   a strict type check is executed so the string representation must be
   the same.
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.array-intersect-key-seealso">
  <h3 class="title">Vedere anche:</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> - Calcola la differenza di due o pi&ugrave; array</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-diff-assoc.php" class="function" rel="rdfs-seeAlso">array_diff_assoc()</a> - Calcola la differenza tra array con un ulteriore controllo sull'indice</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-diff-key.php" class="function" rel="rdfs-seeAlso">array_diff_key()</a> - Computes the difference of arrays using keys for comparison</span></li>
    <li><span class="function"><a href="function.array-diff-ukey.php" class="function" rel="rdfs-seeAlso">array_diff_ukey()</a> - Computes the difference of arrays using a callback function on the keys for comparison</span></li>
    <li><span class="function"><a href="function.array-intersect.php" class="function" rel="rdfs-seeAlso">array_intersect()</a> - Calcola l'intersezione degli arrays</span></li>
    <li><span class="function"><a href="function.array-intersect-assoc.php" class="function" rel="rdfs-seeAlso">array_intersect_assoc()</a> - Calcola l'intersezione degli array con un ulteriore controllo sugli indici</span></li>
    <li><span class="function"><a href="function.array-intersect-uassoc.php" class="function" rel="rdfs-seeAlso">array_intersect_uassoc()</a> - Computes the intersection of arrays with additional index check, compares indexes by a callback function</span></li>
    <li><span class="function"><a href="function.array-intersect-ukey.php" class="function" rel="rdfs-seeAlso">array_intersect_ukey()</a> - Computes the intersection of arrays using a callback function on the keys for comparison</span></li>
   </ul>
  </p>
 </div>

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