- <?php
- function ShakeIt($string)
- {
- $sortie = "";
- $pattern = "/([\s,<>\"\.?!@;:'-]+)/";
-
- $tableau = preg_split($pattern,$string);
- preg_match_all($pattern,$string,$separateurs);
-
-
- foreach($tableau as $cle => $mot)
- {
- if(strlen($mot) > 3)
- {
- $cut = array_slice(split("-l-", chunk_split($mot,1, '-l-')), 0, -1);
- $mot2 = $cut[0];
- $array2 = Array();
- for($i = 1;$i < (strlen($mot) - 1); $i++)
- {
- $array2[$i] = $cut[$i];
- }
- shuffle($array2);
- for($i = 0;$i < (strlen($mot) - 1); $i++)
- {
- $mot2 .= $array2[$i];
- }
- $mot = $mot2 . $cut[strlen($mot) - 1];
- }
-
- $sortie .= $mot . $separateurs[0][$cle];
- }
- return $sortie;
- }
-
- echo ShakeIt("Bonjour ! Ceci donne un petit exemple de la fonction que j'ai réalisé ! Impressionnant n'est-ce pas ? Votre cerveau lit le mot comme un tout !");
-
- ?>
<?php
function ShakeIt($string)
{
$sortie = "";
$pattern = "/([\s,<>\"\.?!@;:'-]+)/";
$tableau = preg_split($pattern,$string);
preg_match_all($pattern,$string,$separateurs);
foreach($tableau as $cle => $mot)
{
if(strlen($mot) > 3)
{
$cut = array_slice(split("-l-", chunk_split($mot,1, '-l-')), 0, -1);
$mot2 = $cut[0];
$array2 = Array();
for($i = 1;$i < (strlen($mot) - 1); $i++)
{
$array2[$i] = $cut[$i];
}
shuffle($array2);
for($i = 0;$i < (strlen($mot) - 1); $i++)
{
$mot2 .= $array2[$i];
}
$mot = $mot2 . $cut[strlen($mot) - 1];
}
$sortie .= $mot . $separateurs[0][$cle];
}
return $sortie;
}
echo ShakeIt("Bonjour ! Ceci donne un petit exemple de la fonction que j'ai réalisé ! Impressionnant n'est-ce pas ? Votre cerveau lit le mot comme un tout !");
?>