mirror of
https://github.com/php/doc-it.git
synced 2026-03-24 07:32:12 +01:00
git-svn-id: https://svn.php.net/repository/phpdoc/it/trunk@314704 c90b9560-bf6c-de11-be94-00142212c4b1
105 lines
3.2 KiB
XML
105 lines
3.2 KiB
XML
<?xml version="1.0" encoding="UTF-8"?>
|
|
<!-- splitted from ./it/functions/array.xml, last change in rev 1.1 -->
|
|
<!-- last change to 'compact' in en/ tree in rev 1.2 -->
|
|
<!-- EN-Revision: n/a Maintainer: cucinato Status: ready -->
|
|
<!-- OLD-Revision: 1.173/EN.1.2 -->
|
|
<refentry xml:id="function.compact" xmlns="http://docbook.org/ns/docbook">
|
|
<refnamediv>
|
|
<refname>compact</refname>
|
|
<refpurpose>
|
|
Crea un array contenente variabili e il loro valore
|
|
</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Descrizione</title>
|
|
<methodsynopsis>
|
|
<type>array</type><methodname>compact</methodname>
|
|
<methodparam><type>mixed</type><parameter>varname</parameter></methodparam>
|
|
<methodparam choice="opt"><type>mixed</type><parameter>...</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
<function>compact</function> accetta un numero variabile di
|
|
parametri. Ogni parametro può essere una stringa contenente il
|
|
nome della variabile, o un array di nomi di variabile. L'array
|
|
può contenere altri array di nomi di variabile;
|
|
<function>compact</function> se ne occupa in modo ricorsivo.
|
|
</para>
|
|
<para>
|
|
Per ognuno di questi, <function>compact</function> cerca la
|
|
variabile con quel nome nella tabella dei simboli corrente, e la aggiunge
|
|
all'array di output in modo tale che il nome della variabile diventi la chiave
|
|
e i contenuti della variabile diventino il valore associato a quella chiave.
|
|
In breve, <function>compact</function> è l'opposto di <function>extract</function>.
|
|
Restituisce l'array di output con tutte le variabili aggiunte a quest'ultimo.
|
|
</para>
|
|
<para>
|
|
Qualsiasi stringa non valorizzata verrà semplicemente ignorata.
|
|
</para>
|
|
<note>
|
|
<title>Gotcha</title>
|
|
<para>
|
|
Dal momento che le <link linkend="language.variables.variable">variabili
|
|
variabili</link> non posso essere utilizzate con gli
|
|
<link linkend="language.variables.superglobals">array
|
|
Superglobal</link> di PHP nelle funzioni, gli array Superglobal non possono essere passati
|
|
alla funzione <function>compact</function>.
|
|
</para>
|
|
</note>
|
|
<para>
|
|
<example>
|
|
<title>esempio di <function>compact</function></title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
$citta = "Milano";
|
|
$provincia = "MI";
|
|
$evento = "SMAU";
|
|
|
|
$var_luoghi = array("citta", "provincia");
|
|
|
|
$risultato = compact("evento", "niente", $var_luoghi);
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
<para>
|
|
In questo modo, <varname>$risultato</varname> sarà:
|
|
</para>
|
|
<screen role="php">
|
|
<![CDATA[
|
|
Array
|
|
(
|
|
[event] => SMAU
|
|
[citta] => Milano
|
|
[provincia] => MI
|
|
)
|
|
]]>
|
|
</screen>
|
|
</example>
|
|
</para>
|
|
<para>
|
|
Vedere anche <function>extract</function>.
|
|
</para>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<!-- Keep this comment at the end of the file
|
|
Local variables:
|
|
mode: sgml
|
|
sgml-omittag:t
|
|
sgml-shorttag:t
|
|
sgml-minimize-attributes:nil
|
|
sgml-always-quote-attributes:t
|
|
sgml-indent-step:1
|
|
sgml-indent-data:t
|
|
indent-tabs-mode:nil
|
|
sgml-parent-document:nil
|
|
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
|
|
sgml-exposed-tags:nil
|
|
sgml-local-catalogs:nil
|
|
sgml-local-ecat-files:nil
|
|
End:
|
|
vim600: syn=xml fen fdm=syntax fdl=2 si
|
|
vim: et tw=78 syn=sgml
|
|
vi: ts=1 sw=1
|
|
-->
|