mirror of
https://github.com/php/doc-de.git
synced 2026-03-25 15:52:10 +01:00
fixed svn properties git-svn-id: https://svn.php.net/repository/phpdoc/de/trunk@283886 c90b9560-bf6c-de11-be94-00142212c4b1
155 lines
3.9 KiB
XML
155 lines
3.9 KiB
XML
<?xml version="1.0" encoding="iso-8859-1"?>
|
|
<!-- $Revision$ -->
|
|
<!-- EN-Revision: n/a Maintainer: nobody Status: ready -->
|
|
<!-- CREDITS: tom -->
|
|
<refentry xml:id="function.list" xmlns="http://docbook.org/ns/docbook">
|
|
<refnamediv>
|
|
<refname>list</refname>
|
|
<refpurpose>Weist Variablen zu, als wären sie ein Array</refpurpose>
|
|
</refnamediv>
|
|
<refsect1 role="description">
|
|
&reftitle.description;
|
|
<methodsynopsis>
|
|
<type>void</type><methodname>list</methodname>
|
|
<methodparam><type>mixed</type><parameter>varname</parameter></methodparam>
|
|
<methodparam rep="repeat"><type>mixed</type><parameter>...</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
Wie <function>array</function> ist auch dies keine wirkliche
|
|
Funktion, sondern ein Sprachkonstrukt. <function>list</function>
|
|
wird verwendet, um eine Liste von Variablen innerhalb einer
|
|
Operation zuzuweisen.
|
|
</para>
|
|
<note>
|
|
<para>
|
|
<function>list</function> funktioniert nur bei numerischen Arrays und
|
|
basiert auf der Annahme, dass die numerischen Indizes bei 0 beginnen.
|
|
</para>
|
|
</note>
|
|
<para>
|
|
<example>
|
|
<title><function>list</function></title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
|
|
$info = array('Kaffee', 'braun', 'Koffein');
|
|
|
|
// Auflisten aller Variablen
|
|
list($drink, $color, $power) = $info;
|
|
echo "$drink ist $color und $power macht es zu etwas besonderem.\n";
|
|
|
|
// Ein paar davon auflisten
|
|
list($drink, , $power) = $info;
|
|
echo "$drink hat $power.\n";
|
|
|
|
// Oder nur die dritte ausgeben
|
|
list( , , $power) = $info;
|
|
echo "Ich brauche $power!\n";
|
|
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
</para>
|
|
<para>
|
|
<example>
|
|
<title><function>list</function></title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<table>
|
|
<tr>
|
|
<th>Mitarbeitername</th>
|
|
<th>Gehalt</th>
|
|
</tr>
|
|
|
|
<?php
|
|
|
|
$result = mysql_query ("SELECT id, name, salary FROM employees",$conn);
|
|
while (list ($id, $name, $salary) = mysql_fetch_row ($result)) {
|
|
echo " <tr>\n".
|
|
" <td><a href=\"info.php?id=$id\">$name</a></td>\n".
|
|
" <td>$salary</td>\n".
|
|
" </tr>\n";
|
|
}
|
|
|
|
?>
|
|
|
|
</table>
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
</para>
|
|
<warning>
|
|
<para>
|
|
<function>list</function> weist die Werte von rechts beginnend zu.
|
|
Wenn Sie einfache Variablen benutzen, brauchen Sie sich nicht darum
|
|
zu kümmern. Wenn Sie jedoch Arrays mit Indizes verwenden, erwarten Sie
|
|
gewöhnlich die Reihenfolge der Indizes in dem Array genau so, wie Sie
|
|
sie in <function>list</function> geschrieben haben (von links nach
|
|
rechts), was jedoch nicht der Fall ist. Es wird in der umgekehrten
|
|
Reihenfolge zugewiesen.
|
|
</para>
|
|
</warning>
|
|
<para>
|
|
<example>
|
|
<title><function>list</function> mit Array Indizes verwenden</title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
|
|
$info = array('coffee', 'brown', 'caffeine');
|
|
|
|
list($a[0], $a[1], $a[2]) = $info;
|
|
|
|
var_dump($a);
|
|
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
<para>
|
|
Die Ausgabe (Beachten Sie die Reihenfolge der Elemente, verglichen mit
|
|
der in <function>list</function> eingetragenen Reihenfolge):
|
|
</para>
|
|
<screen>
|
|
<![CDATA[
|
|
array(3) {
|
|
[2]=>
|
|
string(8) "caffeine"
|
|
[1]=>
|
|
string(5) "brown"
|
|
[0]=>
|
|
string(6) "coffee"
|
|
}
|
|
]]>
|
|
</screen>
|
|
</example>
|
|
</para>
|
|
<para>
|
|
Siehe auch <function>each</function>, <function>array</function>
|
|
und <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
|
|
-->
|