<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/ref.strings.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'fr',
  ),
  'this' => 
  array (
    0 => 'function.str-shuffle.php',
    1 => 'str_shuffle',
    2 => 'M&eacute;lange les caract&egrave;res d\'une cha&icirc;ne de caract&egrave;res',
  ),
  'up' => 
  array (
    0 => 'ref.strings.php',
    1 => 'Fonctions sur les cha&icirc;nes de caract&egrave;res',
  ),
  'prev' => 
  array (
    0 => 'function.str-rot13.php',
    1 => 'str_rot13',
  ),
  'next' => 
  array (
    0 => 'function.str-split.php',
    1 => 'str_split',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'fr',
    'path' => 'reference/strings/functions/str-shuffle.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.str-shuffle" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">str_shuffle</h1>
  <p class="verinfo">(PHP 4 &gt;= 4.3.0, PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">str_shuffle</span> &mdash; <span class="dc-title">Mélange les caractères d&#039;une chaîne de caractères</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.str-shuffle-description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>str_shuffle</strong></span>(<span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$string</code></span>): <span class="type"><a href="language.types.string.php" class="type string">string</a></span></div>

  <p class="simpara">
   <span class="function"><strong>str_shuffle()</strong></span> mélange les caractères d&#039;une chaîne.
   Une permutation parmi toutes celles possibles est créée.
  </p>
  <div class="caution"><strong class="caution">Attention</strong>
 <p class="para">
  Cette fonction ne génère pas de valeurs cryptographiquement sûres, et <em>ne doit pas</em>
  être utilisée à des fins cryptographiques, ou à des fins qui exigent que les valeurs renvoyées soient indéchiffrables.
 </p>
 <p class="para">
  Si de l&#039;aléatoire cryptographiquement sûre est requis, le <span class="classname"><a href="class.random-randomizer.php" class="classname">Random\Randomizer</a></span> peut être utilisé
  avec le moteur <span class="classname"><a href="class.random-engine-secure.php" class="classname">Random\Engine\Secure</a></span>. Pour des cas d&#039;usage simple, les fonctions
  <span class="function"><a href="function.random-int.php" class="function">random_int()</a></span> et <span class="function"><a href="function.random-bytes.php" class="function">random_bytes()</a></span> fournissent une <abbr title="Application Programming Interface">API</abbr>
   pratique et sûre qui est qui est soutenu par le <abbr title="Cryptographically Secure PseudoRandom Number Generator">CSPRNG</abbr> du système d&#039;exploitation.
 </p>
</div>
  <div class="caution"><strong class="caution">Attention</strong>
 <p class="simpara">
    Cette fonction utilise l&#039;instance globale Mt19937 (&quot;Mersenne Twister&quot;) comme source d&#039;aléatoire et partage ainsi son état avec toutes les autres fonctions utilisant le Mt19937 global.
    L&#039;utilisation de l&#039;une de ces fonctions fait avancer la séquence pour <em>toutes</em> les autres fonctions, indépendamment de la portée.
  </p>
  <p class="simpara">
    Générer des séquences reproductibles en initialisant <span class="function"><a href="function.mt-srand.php" class="function">mt_srand()</a></span> ou <span class="function"><a href="function.srand.php" class="function">srand()</a></span> avec une valeur connue produira également une sortie reproductible de cette fonction.
  </p>
  <p class="simpara">
    Il est préférable d&#039;utiliser les méthodes de <span class="classname"><a href="class.random-randomizer.php" class="classname">Random\Randomizer</a></span> dans tout nouveau code.
 </p>
</div>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.str-shuffle-parameters">
  <h3 class="title">Liste de paramètres</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">string</code></dt>
     <dd>
      <p class="para">
       La chaîne d&#039;entrée.
      </p>
     </dd>
    
   </dl>
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.str-shuffle-returnvalues">
  <h3 class="title">Valeurs de retour</h3>
  <p class="para">
   Retourne la chaîne mélangée.
  </p>
 </div>

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

     </thead>

     <tbody class="tbody">
      <tr>
       <td>7.1.0</td>
       <td>
        L&#039;algorithme de randomisation <a href="migration71.incompatible.php#migration71.incompatible.rand-srand-aliases" class="link">a été modifié</a> pour utiliser le Générateur de Nombre Aléatoire
        <a href="http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/emt.html" class="link external">&raquo;&nbsp;Mersenne Twister</a> à la place de la fonction rand de libc.
       </td>
      </tr>

     </tbody>
    
   </table>

  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.str-shuffle-examples">
  <h3 class="title">Exemples</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>Exemple #1 Exemple avec <span class="function"><strong>str_shuffle()</strong></span></strong></p>
    <div class="example-contents">
<div class="annotation-interactive phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />$str </span><span style="color: #007700">= </span><span style="color: #DD0000">'abcdef'</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$shuffled </span><span style="color: #007700">= </span><span style="color: #0000BB">str_shuffle</span><span style="color: #007700">(</span><span style="color: #0000BB">$str</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">// Cela va afficher quelque chose comme : bfdaec<br /></span><span style="color: #007700">echo </span><span style="color: #0000BB">$shuffled</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

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


 <div class="refsect1 seealso" id="refsect1-function.str-shuffle-seealso">
  <h3 class="title">Voir aussi</h3>
  <p class="para">
   <ul class="simplelist">
    <li><span class="function"><a href="random-randomizer.shufflebytes.php" class="function" rel="rdfs-seeAlso">Random\Randomizer::shuffleBytes()</a> - Renvoie une permutation par octet d'une cha&icirc;ne de caract&egrave;res</span></li>
    <li><span class="function"><a href="random-randomizer.shufflearray.php" class="function" rel="rdfs-seeAlso">Random\Randomizer::shuffleArray()</a> - Renvoie une permutation d'un tableau</span></li>
   </ul>
  </p>
 </div>


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