mirror of
https://github.com/macintoshplus/doc-fr.git
synced 2026-03-25 09:22:07 +01:00
git-svn-id: https://svn.php.net/repository/phpdoc/fr/trunk@118985 c90b9560-bf6c-de11-be94-00142212c4b1
88 lines
2.7 KiB
XML
88 lines
2.7 KiB
XML
<?xml version="1.0" encoding="iso-8859-1"?>
|
|
<!-- splitted from ./fr/functions/array.xml, last change in rev 1.30 -->
|
|
<!-- last change to 'compact' in en/ tree in rev 1.2 -->
|
|
<refentry id="function.compact">
|
|
<refnamediv>
|
|
<refname>compact</refname>
|
|
<refpurpose>
|
|
Crée un tableau contenant les variables et leur valeur
|
|
</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</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> accepte différents paramètres. 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, que
|
|
<function>compact</function> traitera récursivement.
|
|
</para>
|
|
<para>
|
|
Pour chacun des arguments, <function>compact</function> recherche une variable
|
|
avec une variable de 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>
|
|
<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", $location_vars);
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
<para>
|
|
Après ce programme, <varname>$result</varname> contiendra :
|
|
<screen role="php">
|
|
<![CDATA[
|
|
Array
|
|
(
|
|
[evenement] => conférence PHP Québec
|
|
[ville] => Montréal
|
|
[province] => Québec
|
|
)
|
|
]]>
|
|
</screen>
|
|
</para>
|
|
</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
|
|
-->
|