<?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 => 'pt_BR',
  ),
  'this' => 
  array (
    0 => 'function.str-shuffle.php',
    1 => 'str_shuffle',
    2 => 'Embaralha uma string aleatoriamente',
  ),
  'up' => 
  array (
    0 => 'ref.strings.php',
    1 => 'Fun&ccedil;&otilde;es de String',
  ),
  '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' => 'pt_BR',
    '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">Embaralha uma string aleatoriamente</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.str-shuffle-description">
  <h3 class="title">Descrição</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> embaralha uma string. Uma permutação
   de todas as possíveis é criada.
  </p>
  <div class="caution"><strong class="caution">Cuidado</strong>
 <p class="para">
  Esta função não gera valores criptograficamente seguros e <em>não deve</em>
  ser usada para propósitos criptográficos ou fins que exijam que os valores retornados sejam impossíveis de adivinhar.
 </p>
 <p class="para">
  Se aleatoriedade criptograficamente segura for necessária, a classe <span class="classname"><a href="class.random-randomizer.php" class="classname">Random\Randomizer</a></span> pode ser
  usada com o mecanismo <span class="classname"><a href="class.random-engine-secure.php" class="classname">Random\Engine\Secure</a></span>. Para casos de uso simples, as funções <span class="function"><a href="function.random-int.php" class="function">random_int()</a></span>
  e <span class="function"><a href="function.random-bytes.php" class="function">random_bytes()</a></span> fornecem uma <abbr title="Application Programming Interface">API</abbr> conveniente e segura que é garantida pelo
  <abbr title="Cryptographically Secure PseudoRandom Number Generator">CSPRNG</abbr> do sistema operacional.
 </p>
</div>
  <div class="caution"><strong class="caution">Cuidado</strong>
 <p class="simpara">
  Esta função usa a instância global do Mt19937 (“Mersenne Twister”) como a fonte de aleatoriedade a por isso compartilha seu estado com todas as outras funções que usam o Mt19937 global.
  Usar qualquer uma destas funções avança a sequência para <em>todas</em> as outras funções, independentemente do escopo.
 </p>
 <p class="simpara">
  Gerar sequências repetíveis ao semear <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> com um valor conhecido também gerará saída repetível desta função.
 </p>
 <p class="simpara">
  Prefira usar métodos de <span class="classname"><a href="class.random-randomizer.php" class="classname">Random\Randomizer</a></span> em todo código novo.
 </p>
</div>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.str-shuffle-parameters">
  <h3 class="title">Parâmetros</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">string</code></dt>
     <dd>
      <p class="para">
       A string de entrada.
      </p>
     </dd>
    
   </dl>
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.str-shuffle-returnvalues">
  <h3 class="title">Valor Retornado</h3>
  <p class="para">
   Retorna a string embaralhada.
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-function.str-shuffle-changelog">
  <h3 class="title">Registro de Alterações</h3>
  <p class="para">
   <table class="doctable informaltable">
    
     <thead>
      <tr>
       <th>Versão</th>
       <th>Descrição</th>
      </tr>

     </thead>

     <tbody class="tbody">
      <tr>
       <td>7.1.0</td>
       <td>
        O algoritmo interno de randomização <a href="migration71.incompatible.php#migration71.incompatible.rand-srand-aliases" class="link">mudou</a> e agora usa o Gerador de Números Aleatórios <a href="http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/emt.html" class="link external">&raquo;&nbsp;Mersenne Twister</a> em vez da função rand da biblioteca libc.
       </td>
      </tr>

     </tbody>
    
   </table>

  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.str-shuffle-examples">
  <h3 class="title">Exemplos</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>Exemplo #1 Exemplo de <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">// Isto exibirá algo como: 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">Veja Também</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> - Obt&eacute;m uma permuta&ccedil;&atilde;o byte a byte de uma string</span></li>
    <li><span class="function"><a href="random-randomizer.shufflearray.php" class="function" rel="rdfs-seeAlso">Random\Randomizer::shuffleArray()</a> - Obt&eacute;m uma permuta&ccedil;&atilde;o de um array</span></li>
   </ul>
  </p>
 </div>


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