mirror of
https://github.com/php/doc-de.git
synced 2026-03-24 07:12:15 +01:00
git-svn-id: https://svn.php.net/repository/phpdoc/de/trunk@133570 c90b9560-bf6c-de11-be94-00142212c4b1
152 lines
4.0 KiB
XML
152 lines
4.0 KiB
XML
<?xml version="1.0" encoding="iso-8859-1"?>
|
|
<!-- $Revision: 1.6 $ -->
|
|
<!-- EN-Revision: 1.10 Maintainer: tom Status: ready -->
|
|
<refentry id="function.array">
|
|
<refnamediv>
|
|
<refname>array</refname>
|
|
<refpurpose>
|
|
Erstellt ein Array
|
|
</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Beschreibung</title>
|
|
<methodsynopsis>
|
|
<type>array</type><methodname>array</methodname>
|
|
<methodparam choice="opt"><type>mixed</type><parameter>...</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
Gibt ein den Parametern entsprechendes Array zurück. Mit dem
|
|
<literal>=></literal> Operator können die Parameter indiziert werden.
|
|
Weitere Informationen zu Arrays finden Sie im Abschnitt
|
|
<link linkend="language.types.array">array type</link>.
|
|
</para>
|
|
<para>
|
|
<note>
|
|
<para>
|
|
<function>array</function> ist keine richtige Funktion sondern ein
|
|
Sprachkonstrukt, das zur Erzeugung eines Wertefeldes genutzt wird.
|
|
</para>
|
|
</note>
|
|
</para>
|
|
<para>
|
|
Die Syntax "Index => Werte", durch Kommas getrennt, definiert
|
|
Index und Werte. Index kann vom Typ String oder numerisch sein.
|
|
Wird der Index weggelassen, erstellt die Funktion automatisch
|
|
einen numerischen Index, der bei 0 beginnt. Ist der Index als
|
|
Integer-Wert angegeben, wird der nächste generierte Index der
|
|
größte Integer Index + 1. Beachten Sie, dass wenn zwei identische
|
|
Indexe definiert sind, der letzte den ersten überschreibt.
|
|
</para>
|
|
<para>
|
|
Das folgende Beispiel zeigt wie man ein zweidimensionales Array
|
|
erstellt, wie man Schlüssel für assoziative Arrays festlegt, und
|
|
wie man numerische Indizes in normalen Arrays überspringt und
|
|
fortsetzt.
|
|
<example>
|
|
<title><function>array</function></title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
$fruits = array (
|
|
"Früchte" => array ("a"=>"Orange", "b"=>"Banane", "c"=>"Apfel"),
|
|
"Zahlen" => array (1, 2, 3, 4, 5, 6),
|
|
"Löcher" => array ("erstes", 5 => "zweites", "drittes")
|
|
);
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
</para>
|
|
<para>
|
|
<example>
|
|
<title>Automatischer Index mit <function>array</function></title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
$array = array( 1, 1, 1, 1, 1, 8=>1, 4=>1, 19, 3=>13);
|
|
print_r($array);
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
<para>
|
|
wird folgendes anzeigen:
|
|
</para>
|
|
<screen role="php">
|
|
<![CDATA[
|
|
Array
|
|
(
|
|
[0] => 1
|
|
[1] => 1
|
|
[2] => 1
|
|
[3] => 13
|
|
[4] => 1
|
|
[8] => 1
|
|
[9] => 19
|
|
)
|
|
]]>
|
|
</screen>
|
|
</example>
|
|
</para>
|
|
<para>
|
|
Beachten Sie, dass Index '3' doppelt definiert ist, und den letzten
|
|
definierten Wert 13 behält. Index 4 wurde nach dem Index 8 definiert,
|
|
und der nächste generierte Index (Wert 19) ist 9, da der größte Index
|
|
8 war.
|
|
</para>
|
|
<para>
|
|
Dieses Beispiel erstellt ein auf dem Index 1 basierendes Array.
|
|
<example>
|
|
<title>1-basierter Index mit <function>array</function></title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
$erstesquartal = array(1 => 'Januar', 'Februar', 'März');
|
|
print_r($erstesquartal);
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
<para>
|
|
wird folgendes ausgeben:
|
|
</para>
|
|
<screen>
|
|
<![CDATA[
|
|
Array
|
|
(
|
|
[1] => Januar
|
|
[2] => Februar
|
|
[3] => März
|
|
)
|
|
]]>
|
|
</screen>
|
|
</example>
|
|
</para>
|
|
<para>
|
|
Siehe auch <function>array_pad</function>,
|
|
<function>list</function>,
|
|
<link linkend="control-structures.foreach">foreach</link> und
|
|
<function>range</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
|
|
-->
|