<?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.extract.php',
    1 => 'extract',
    2 => 'Importa le variabili nella tabella dei simboli corrente da un array',
  ),
  'up' => 
  array (
    0 => 'ref.array.php',
    1 => 'Array Funzioni',
  ),
  'prev' => 
  array (
    0 => 'function.end.php',
    1 => 'end',
  ),
  'next' => 
  array (
    0 => 'function.in-array.php',
    1 => 'in_array',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'it',
    'path' => 'reference/array/functions/extract.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.extract" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">extract</h1>
  <p class="verinfo">(PHP 4, PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">extract</span> &mdash; <span class="dc-title">Importa le variabili nella tabella dei simboli corrente da un array</span></p>

 </div>
 <div class="refsect1 description" id="refsect1-function.extract-description">
  <h3 class="title">Descrizione</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>extract</strong></span>(<span class="methodparam"><span class="type"><a href="language.types.array.php" class="type array">array</a></span> <code class="parameter reference">&$array</code></span>, <span class="methodparam"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter">$flags</code><span class="initializer"> = <strong><code><a href="array.constants.php#constant.extr-overwrite">EXTR_OVERWRITE</a></code></strong></span></span>, <span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$prefix</code><span class="initializer"> = &quot;&quot;</span></span>): <span class="type"><a href="language.types.integer.php" class="type int">int</a></span></div>

  <p class="para rdfs-comment">
   Importa le variabili nella tabella dei simboli corrente da un array.
  </p>
  <p class="para">
   Controlla ogni chiave per vedere se ha un nome di variabile valido.
   Controlla anche le collisioni con le variabili esistenti nella
   tabella dei simboli.
  </p>
  <div class="warning"><strong class="warning">Avviso</strong>
   <p class="para">
    Non usare <span class="function"><strong>extract()</strong></span> su dati non attendibili, come l&#039;input dell&#039;utente
    (per esempio <var class="varname"><a href="reserved.variables.get.php" class="classname">$_GET</a></var>, <var class="varname"><a href="reserved.variables.files.php" class="classname">$_FILES</a></var>).
   </p>
  </div>
 </div>

 <div class="refsect1 parameters" id="refsect1-function.extract-parameters">
  <h3 class="title">Elenco dei parametri</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">array</code></dt>
     <dd>
      <p class="para">
       Un array associativo. Questa funzione tratta le chiavi come nomi di variabili e
       i valori come valori di variabili.  Per ogni coppia chiave/valore verrà creata una
       variabile nella tabella dei simboli corrente, soggetta ai
       parametri <code class="parameter">flags</code> e <code class="parameter">prefix</code>.
      </p>
      <p class="para">
       È necessario utilizzare un array associativo; un array indicizzato numericamente
       non produrrà risultati a meno che non si utilizzi <strong><code><a href="array.constants.php#constant.extr-prefix-all">EXTR_PREFIX_ALL</a></code></strong> o
       <strong><code><a href="array.constants.php#constant.extr-prefix-invalid">EXTR_PREFIX_INVALID</a></code></strong>.
      </p>
     </dd>
    
    
     <dt><code class="parameter">flags</code></dt>
     <dd>
      <p class="para">
       Il modo in cui vengono trattate le chiavi non valide/numeriche e le collisioni è determinato
       dai <code class="parameter">flag</code> di estrazione. Può essere uno dei
       seguenti valori:
       <dl>
        
         <dt><strong><code><a href="array.constants.php#constant.extr-overwrite">EXTR_OVERWRITE</a></code></strong></dt>
         <dd>
          <span class="simpara">
           In caso di collisione, sovrascrivi la variabile esistente.
          </span>
         </dd>
        
        
         <dt><strong><code><a href="array.constants.php#constant.extr-skip">EXTR_SKIP</a></code></strong></dt>
         <dd>
          <span class="simpara">
           In caso di collisione, non sovrascrivere la variabile
           esistente.
          </span>
         </dd>
        
        
         <dt><strong><code><a href="array.constants.php#constant.extr-prefix-same">EXTR_PREFIX_SAME</a></code></strong></dt>
         <dd>
          <span class="simpara">In caso di collisione, anteporre al nome della variabile il prefisso
           <code class="parameter">prefix</code>.
          </span>
         </dd>
        
        
         <dt><strong><code><a href="array.constants.php#constant.extr-prefix-all">EXTR_PREFIX_ALL</a></code></strong></dt>
         <dd>
          <span class="simpara">
           Prefissa tutti i nomi delle variabili con
           <code class="parameter">prefix</code>.
          </span>
         </dd>
        
        
         <dt><strong><code><a href="array.constants.php#constant.extr-prefix-invalid">EXTR_PREFIX_INVALID</a></code></strong></dt>
         <dd>
          <span class="simpara">
           Aggiunge il prefisso <code class="parameter">prefix</code> solo ai nomi di variabili
           non valide/numeriche.
          </span>
         </dd>
        
        
         <dt><strong><code><a href="array.constants.php#constant.extr-if-exists">EXTR_IF_EXISTS</a></code></strong></dt>
         <dd>
          <span class="simpara">
           Sovrascrive la variabile solo se esiste già nella
           tabella dei simboli corrente, altrimenti non fa nulla.  Questo è utile
           per definire un elenco di variabili valide e quindi estrarre
           solo quelle variabili che sono state definite in
           <var class="varname"><a href="reserved.variables.request.php" class="classname">$_REQUEST</a></var>, per esempio.
          </span>
         </dd>
        
        
         <dt><strong><code><a href="array.constants.php#constant.extr-prefix-if-exists">EXTR_PREFIX_IF_EXISTS</a></code></strong></dt>
         <dd>
          <span class="simpara">
           Crea nomi di variabili con prefisso solo se la versione senza prefisso
           della stessa variabile esiste nella tabella dei simboli corrente.
          </span>
         </dd>
        
        
         <dt><strong><code><a href="array.constants.php#constant.extr-refs">EXTR_REFS</a></code></strong></dt>
         <dd>
          <span class="simpara">
           Estrae le variabili come riferimenti. Ciò significa effettivamente che i
           valori delle variabili importate fanno ancora riferimento ai valori del
           parametro <code class="parameter">array</code>. Si può usare questo flag
           da solo o combinarlo con qualsiasi altro flag utilizzando l&#039;OR dei
           <code class="parameter">flags</code>.
          </span>
         </dd>
        
       </dl>
      </p>
      <p class="para">
       Se <code class="parameter">flags</code> non è specificato, si
       presume che sia <strong><code><a href="array.constants.php#constant.extr-overwrite">EXTR_OVERWRITE</a></code></strong>.
      </p>
     </dd>
    
    
     <dt><code class="parameter">prefix</code></dt>
     <dd>
      <p class="para">
       Notare che <code class="parameter">prefix</code> è richiesto solo se
       <code class="parameter">flags</code> è <strong><code><a href="array.constants.php#constant.extr-prefix-same">EXTR_PREFIX_SAME</a></code></strong>,
       <strong><code><a href="array.constants.php#constant.extr-prefix-all">EXTR_PREFIX_ALL</a></code></strong>, <strong><code><a href="array.constants.php#constant.extr-prefix-invalid">EXTR_PREFIX_INVALID</a></code></strong>
       o <strong><code><a href="array.constants.php#constant.extr-prefix-if-exists">EXTR_PREFIX_IF_EXISTS</a></code></strong>. Se
       il risultato con prefisso non è un nome di variabile valido, non viene
       importato nella tabella dei simboli. I prefissi vengono separati automaticamente dalla
       chiave dell&#039;array da un carattere underscore.
      </p>
     </dd>
    
   </dl>
  </p>
 </div>

 <div class="refsect1 returnvalues" id="refsect1-function.extract-returnvalues">
  <h3 class="title">Valori restituiti</h3>
  <p class="para">
   Restituisce il numero di variabili importate con successo nella tabella dei
   simboli.
  </p>
 </div>

 <div class="refsect1 examples" id="refsect1-function.extract-examples">
  <h3 class="title">Esempi</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>Example #1 Esempio di <span class="function"><strong>extract()</strong></span></strong></p>
    <div class="example-contents"><p>
     Un possibile utilizzo di <span class="function"><strong>extract()</strong></span> è importare nella
     tabella dei simboli le variabili contenute in un array associativo restituito da
     <span class="function"><a href="function.wddx-deserialize.php" class="function">wddx_deserialize()</a></span>.
    </p></div>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /><br /></span><span style="color: #FF8000">/* Si supponga che $var_array sia un array restituito da<br />   wddx_deserialize */<br /><br /></span><span style="color: #0000BB">$size </span><span style="color: #007700">= </span><span style="color: #DD0000">"grande"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$array_variabili </span><span style="color: #007700">= array(</span><span style="color: #DD0000">"color" </span><span style="color: #007700">=&gt; </span><span style="color: #DD0000">"blu"</span><span style="color: #007700">,<br />                         </span><span style="color: #DD0000">"size"  </span><span style="color: #007700">=&gt; </span><span style="color: #DD0000">"media"</span><span style="color: #007700">,<br />                         </span><span style="color: #DD0000">"shape" </span><span style="color: #007700">=&gt; </span><span style="color: #DD0000">"sfera"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">extract</span><span style="color: #007700">(</span><span style="color: #0000BB">$array_variabili</span><span style="color: #007700">, </span><span style="color: #0000BB">EXTR_PREFIX_SAME</span><span style="color: #007700">, </span><span style="color: #DD0000">"wddx"</span><span style="color: #007700">);<br /><br />echo </span><span style="color: #DD0000">"</span><span style="color: #0000BB">$color</span><span style="color: #DD0000">, </span><span style="color: #0000BB">$size</span><span style="color: #DD0000">, </span><span style="color: #0000BB">$shape</span><span style="color: #DD0000">, </span><span style="color: #0000BB">$wddx_size</span><span style="color: #DD0000">\n"</span><span style="color: #007700">;<br /><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">blu, grande, sfera, media</pre>
</div>
    </div>
    <div class="example-contents"><p>
     <var class="varname">$size</var> non è stato sovrascritto perché abbiamo specificato
     <strong><code><a href="array.constants.php#constant.extr-prefix-same">EXTR_PREFIX_SAME</a></code></strong>, che ha portato alla
     creazione di <var class="varname">$wddx_size</var>. Se fosse stato specificato
     <strong><code><a href="array.constants.php#constant.extr-skip">EXTR_SKIP</a></code></strong>, allora <var class="varname">$wddx_size</var> non sarebbe nemmeno stato creato.
     <strong><code><a href="array.constants.php#constant.extr-overwrite">EXTR_OVERWRITE</a></code></strong> avrebbe fatto sì che <var class="varname">$size</var> avesse
     il valore &quot;medio&quot; e <strong><code><a href="array.constants.php#constant.extr-prefix-all">EXTR_PREFIX_ALL</a></code></strong> avrebbe comportato nuove variabili
     con nomi <var class="varname">$wddx_color</var>,
     <var class="varname">$wddx_size</var> e
     <var class="varname">$wddx_shape</var>.
    </p></div>
   </div>
  </p>
 </div>

 <div class="refsect1 notes" id="refsect1-function.extract-notes">
  <h3 class="title">Note</h3>
  <div class="warning"><strong class="warning">Avviso</strong>
   <p class="para">
    Non utilizzare <span class="function"><strong>extract()</strong></span> su dati non attendibili, come
    l&#039;input dell&#039;utente
    (per esempio <var class="varname"><a href="reserved.variables.get.php" class="classname">$_GET</a></var>, <var class="varname"><a href="reserved.variables.files.php" class="classname">$_FILES</a></var>, ecc.).
    In tal caso, assicurarsi di utilizzare uno dei valori di <code class="parameter">flags</code>
    che non sovrascrivono come
    <strong><code><a href="array.constants.php#constant.extr-skip">EXTR_SKIP</a></code></strong> e tenere presente che si dovrebbe estrarre
    nello stesso ordine definito in
    <a href="ini.core.php#ini.variables-order" class="link">variables_order</a> all&#039;interno del
    <a href="ini.php" class="link"><var class="filename">php.ini</var></a>.
   </p>
  </div>
 </div>

 <div class="refsect1 seealso" id="refsect1-function.extract-seealso">
  <h3 class="title">Vedere anche:</h3>
  <p class="para">
   <ul class="simplelist">
    <li><span class="function"><a href="function.compact.php" class="function" rel="rdfs-seeAlso">compact()</a> - Crea un array contenente variabili e il loro valore</span></li>
    <li><span class="function"><a href="function.list.php" class="function" rel="rdfs-seeAlso">list()</a> - Assegna valori a delle variabili come se fossero un array</span></li>
   </ul>
  </p>
 </div>

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