1
0
mirror of https://github.com/php/doc-de.git synced 2026-03-29 10:42:12 +02:00
Files
archived-doc-de/reference/array/functions/compact.xml
2006-01-24 20:21:47 +00:00

105 lines
3.0 KiB
XML

<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.7 $ -->
<!-- EN-Revision: 1.8 Maintainer: simp Status: ready -->
<!-- CREDITS: tom -->
<refentry id="function.compact">
<refnamediv>
<refname>compact</refname>
<refpurpose>
Erstellt ein Array mit Variablen und deren Werten
</refpurpose>
</refnamediv>
<refsect1>
<title>Beschreibung</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> übernimmt eine variable Anzahl von
Parametern. Jeder Parameter kann entweder ein String mit einem
Variablennamen, oder ein Array mit Variablennamen sein. Dieses
Array kann auch andere Arrays mit Variablennamen enthalten;
<function>compact</function> behandelt sie rekursiv.
</para>
<para>
Für alle diese sucht <function>compact</function> nach einer
Variablen in der aktuellen Symboltabelle, und fügt diese dem
zurückzugebenden Array hinzu, wobei der Variablenname als
Schlüssel, und der Inhalt der Variablen als Wert gespeichert
wird. Kurz, diese Funktion tut das Gegenteil von
<function>extract</function>. Sie gibt ein Array mit allen
Variablen zurück.
</para>
<para>
Strings, welche nicht gesetzt sind, werden einfach ignoriert.
</para>
<note>
<title>Achtung</title>
<para>
Weil <link linkend="language.variables.variable"> variable
Variablen</link> nicht mit PHPs <link linkend="language.variables.superglobals">
superglobalen Arrays</link> verwendet werden dürfen, können die
superglobalen Arrays nicht an <function>compact</function>
übergeben werden.
</para>
</note>
<para>
<example>
<title><function>compact</function></title>
<programlisting role="php">
<![CDATA[
<?php
$stadt = "San Francisco";
$staat = "CA";
$ereignis = "SIGGRAPH";
$location_vars = array("stadt", "staat");
$result = compact("ereignis", "nichts_hier", $location_vars);
?>
]]>
</programlisting>
<para>
Danach wird <varname>$result</varname>:
</para>
<screen role="php">
<![CDATA[
Array
(
[ereignis] => SIGGRAPH
[stadt] => San Francisco
[staat] => CA
)
]]>
</screen>
</example>
</para>
<para>
Siehe auch <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
-->