<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/ref.array.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'de',
  ),
  'this' => 
  array (
    0 => 'function.shuffle.php',
    1 => 'shuffle',
    2 => 'Mischt die Elemente eines Arrays',
  ),
  'up' => 
  array (
    0 => 'ref.array.php',
    1 => 'Array Funktionen',
  ),
  'prev' => 
  array (
    0 => 'function.rsort.php',
    1 => 'rsort',
  ),
  'next' => 
  array (
    0 => 'function.sizeof.php',
    1 => 'sizeof',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'de',
    'path' => 'reference/array/functions/shuffle.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.shuffle" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">shuffle</h1>
  <p class="verinfo">(PHP 4, PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">shuffle</span> &mdash; <span class="dc-title">Mischt die Elemente eines Arrays</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.shuffle-description">
  <h3 class="title">Beschreibung</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>shuffle</strong></span>(<span class="methodparam"><span class="type"><a href="language.types.array.php" class="type array">array</a></span> <code class="parameter reference">&$array</code></span>): <span class="type"><a href="language.types.singleton.php" class="type true">true</a></span></div>

  <p class="para rdfs-comment">
   Diese Funktion mischt die Elemente eines Arrays zufällig (shuffle).
  </p>
  <div class="caution"><strong class="caution">Achtung</strong>
 <p class="para">
  Diese Funktion erzeugt keine kryptografisch sicheren Werte und
  <em>darf nicht</em> für kryptografische Zwecke verwendet werden
  oder für Zwecke, bei denen die zurückgegebenen Werte nicht abschätzbar sein
  dürfen.
 </p>
 <p class="para">
  Falls kryptographisch sichere Zufallszahlen benötigt werden, kann der
  <span class="classname"><a href="class.random-randomizer.php" class="classname">Random\Randomizer</a></span> mit der
  <span class="classname"><a href="class.random-engine-secure.php" class="classname">Random\Engine\Secure</a></span>-Engine verwendet werden. Für
  einfache Anwendungsfälle bieten die Funktionen <span class="function"><a href="function.random-int.php" class="function">random_int()</a></span>
  und <span class="function"><a href="function.random-bytes.php" class="function">random_bytes()</a></span> eine bequeme und sichere
  <abbr title="Application Programming Interface">API</abbr>, die den <abbr title="Cryptographically Secure PseudoRandom Number Generator">CSPRNG</abbr> des
  Betriebssystems verwendet.
 </p>
</div>
  <div class="caution"><strong class="caution">Achtung</strong>
 <p class="simpara">
    This function uses the global Mt19937 (“Mersenne Twister”) instance as the source of randomness and thus shares its state with all other functions using the global Mt19937.
    Using any of these functions advances the sequence for <em>all</em> the other functions, regardless of scope.
  </p>
  <p class="simpara">
    Generating repeatable sequences by seeding <span class="function"><a href="function.mt-srand.php" class="function">mt_srand()</a></span> or <span class="function"><a href="function.srand.php" class="function">srand()</a></span> with a known value will also yield repeatable output from this function.
  </p>
  <p class="simpara">
    Prefer using <span class="classname"><a href="class.random-randomizer.php" class="classname">Random\Randomizer</a></span> methods in all newly written code.
 </p>
</div>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.shuffle-parameters">
  <h3 class="title">Parameter-Liste</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">array</code></dt>
     <dd>
      <p class="para">
       Das zu modifizierende Array.
      </p>
     </dd>
    
   </dl>
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.shuffle-returnvalues">
  <h3 class="title">Rückgabewerte</h3>
  <p class="para">
   Gibt immer <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong> zurück.
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-function.shuffle-changelog">
  <h3 class="title">Changelog</h3>
  <p class="para">
   <table class="doctable informaltable">
    
     <thead>
      <tr>
       <th>Version</th>
       <th>Beschreibung</th>
      </tr>

     </thead>

     <tbody class="tbody">
      <tr>
       <td>7.1.0</td>
       <td>
        Der interne Algorithmus zur Erzeugung von Zufallszahlen
        <a href="migration71.incompatible.php#migration71.incompatible.rand-srand-aliases" class="link">wurde geändert</a>,
        sodass statt der libc-rand-Funktion nun der
        <a href="http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/emt.html" class="link external">&raquo;&nbsp;Mersenne-Twister</a>-Zufallszahlengenerator
        zum Einsatz kommt.
       </td>
      </tr>

     </tbody>
    
   </table>

  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.shuffle-examples">
  <h3 class="title">Beispiele</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>Beispiel #1 <span class="function"><strong>shuffle()</strong></span>-Beispiel</strong></p>
    <div class="example-contents">
<div class="annotation-interactive phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />$numbers </span><span style="color: #007700">= </span><span style="color: #0000BB">range</span><span style="color: #007700">(</span><span style="color: #0000BB">1</span><span style="color: #007700">, </span><span style="color: #0000BB">20</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">shuffle</span><span style="color: #007700">(</span><span style="color: #0000BB">$numbers</span><span style="color: #007700">);<br />foreach (</span><span style="color: #0000BB">$numbers </span><span style="color: #007700">as </span><span style="color: #0000BB">$number</span><span style="color: #007700">) {<br />    echo </span><span style="color: #DD0000">"</span><span style="color: #0000BB">$number</span><span style="color: #DD0000"> "</span><span style="color: #007700">;<br />}<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

   </div>
  </p>
 </div>


 <div class="refsect1 notes" id="refsect1-function.shuffle-notes">
  <h3 class="title">Anmerkungen</h3>
  <blockquote class="note"><p><strong class="note">Hinweis</strong>: <span class="simpara">Diese Funktion weist den
Elementen des Arrays <code class="parameter">array</code> neue Schlüssel zu.
Bestehende Schlüssel, die bereits zugewiesen wurden, werden entfernt
statt einfach nur die Schlüssel neu anzuordnen</span></p></blockquote>
  <blockquote class="note"><p><strong class="note">Hinweis</strong>: 
 <p class="para">
  Setzt den internen Zeiger des Arrays auf das erste Element zurück.
 </p>
</p></blockquote>

 </div>


 <div class="refsect1 seealso" id="refsect1-function.shuffle-seealso">
  <h3 class="title">Siehe auch</h3>
  <p class="para">
   <ul class="simplelist">
    <li><span class="function"><a href="random-randomizer.shufflearray.php" class="function" rel="rdfs-seeAlso">Random\Randomizer::shuffleArray()</a> - Get a permutation of an array</span></li>
    <li><span class="function"><a href="random-randomizer.shufflebytes.php" class="function" rel="rdfs-seeAlso">Random\Randomizer::shuffleBytes()</a> - Get a byte-wise permutation of a string</span></li>
    <li><span class="function"><a href="random-randomizer.pickarraykeys.php" class="function" rel="rdfs-seeAlso">Random\Randomizer::pickArrayKeys()</a> - Select random array keys</span></li>
    <li>Den <a href="array.sorting.php" class="link">Vergleich von Arraysortierungsfunktionen</a></li>
   </ul>
  </p>
 </div>


</div><?php manual_footer($setup); ?>