1
0
mirror of https://github.com/php/doc-de.git synced 2026-03-31 19:52:21 +02:00
Files
archived-doc-de/reference/array/functions/array-rand.xml
Hannes Magnusson 97d53b218c Upgrade to DocBook5:
- All id attributes are now xml:id
 - Add docbook namespace to all root elements
 - Replace <ulink /> with <link xlink:href />
 - Minor markup fixes here and there
 - Bump EN-Revision where appropriate


git-svn-id: https://svn.php.net/repository/phpdoc/de/trunk@238322 c90b9560-bf6c-de11-be94-00142212c4b1
2007-06-23 13:21:53 +00:00

79 lines
2.4 KiB
XML

<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.8 $ -->
<!-- EN-Revision: 1.11 Maintainer: simp Status: ready -->
<!-- CREDITS: tom -->
<refentry xml:id="function.array-rand" xmlns="http://docbook.org/ns/docbook">
<refnamediv>
<refname>array_rand</refname>
<refpurpose>Liefert einen oder mehrere zufällige Einträge eines Arrays</refpurpose>
</refnamediv>
<refsect1>
<title>Beschreibung</title>
<methodsynopsis>
<type>mixed</type><methodname>array_rand</methodname>
<methodparam><type>array</type><parameter>input</parameter></methodparam>
<methodparam choice="opt"><type>int</type><parameter>num_req</parameter></methodparam>
</methodsynopsis>
<para>
<function>array_rand</function> ist ziemlich nützlich, wenn Sie
einen oder mehrere zufällige Einträge eines Arrays auswählen
möchten. Die Funktion übernimmt das Array
<parameter>input</parameter>, und ein optionales Argument
<parameter>num_req</parameter>, welches die gewünschte Anzahl
Einträge spezifiziert. Ist <parameter>num_req</parameter> nicht
angegeben, wird ein Defaultwert von 1 angenommen.
</para>
<para>
Wenn Sie nur einen Eintrag auswählen, liefert
<function>array_rand</function> den Schlüssel eines zufälligen
Eintrages. Andernfalls wird ein Array mit den Schlüsseln der
zufälligen Einträge zurückgegeben. Dies hat den Zweck, dass Sie
zufällige Schlüssel und auch Werte aus dem Array auswählen
können.
</para>
&note.randomseed;
<para>
<example>
<title><function>array_rand</function></title>
<programlisting role="php">
<![CDATA[
<?php
srand((float) microtime() * 10000000);
$input = array("Neo", "Morpheus", "Trinity", "Cypher", "Tank");
$rand_keys = array_rand($input, 2);
echo $input[$rand_keys[0]] . "\n";
echo $input[$rand_keys[1]] . "\n";
?>
]]>
</programlisting>
</example>
</para>
<para>
Siehe auch <function>shuffle</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
-->