mirror of
https://github.com/macintoshplus/doc-fr.git
synced 2026-03-26 01:42:09 +01:00
git-svn-id: https://svn.php.net/repository/phpdoc/fr/trunk@171861 c90b9560-bf6c-de11-be94-00142212c4b1
92 lines
2.6 KiB
XML
92 lines
2.6 KiB
XML
<?xml version="1.0" encoding="iso-8859-1"?>
|
|
<!-- $Revision: 1.13 $ -->
|
|
<!-- EN-Revision: 1.7 Maintainer: didou Status: ready -->
|
|
<refentry id="function.compact">
|
|
<refnamediv>
|
|
<refname>compact</refname>
|
|
<refpurpose>
|
|
Crée un tableau à partir de variables et de leur valeur
|
|
</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
&reftitle.description;
|
|
<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> accepte différents paramètres <parameter>varname</parameter>.
|
|
Les paramètres peuvent être des variables contenant des chaînes,
|
|
ou un tableau de chaînes, qui peut contenir d'autres tableaux de noms de
|
|
variables, que <function>compact</function> traitera récursivement.
|
|
</para>
|
|
<para>
|
|
Pour chacun des arguments <parameter>varname</parameter>, <parameter>...</parameter>,
|
|
<function>compact</function> recherche une variable
|
|
avec un même nom dans la table courante des symboles, et
|
|
l'ajoute dans le tableau, de manière à avoir la relation nom =>
|
|
'valeur de variable'. En bref, c'est le contraire de la fonction
|
|
<function>extract</function>. <function>compact</function> retourne
|
|
le tableau ainsi créé.
|
|
</para>
|
|
<para>
|
|
Toute chaîne non reconnue dans la table des symboles sera tout simplement
|
|
ignorée.
|
|
</para>
|
|
<para>
|
|
<example>
|
|
<title>Exemple avec <function>compact</function></title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
$ville = "Montréal";
|
|
$province = "Québec";
|
|
$evenement = "Conférence PHP Québec";
|
|
$location_vars = array("ville", "province");
|
|
$result = compact("evenement", "rien ici", $location_vars);
|
|
print_r($result);
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
&example.outputs;
|
|
<screen role="php">
|
|
<![CDATA[
|
|
Array
|
|
(
|
|
[evenement] => Conférence PHP Québec
|
|
[ville] => Montréal
|
|
[province] => Québec
|
|
)
|
|
]]>
|
|
</screen>
|
|
</example>
|
|
</para>
|
|
<para>
|
|
Voir aussi
|
|
<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:"../../../../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
|
|
-->
|