超越PHP PHP动态 | 经典文章 | CLASS | 相关下载 | 常见问题 | FORUM | WIKI | 在线手册
Site search:    
<str_rot13str_split>
Last updated: Fri, 22 Jun 2007

str_shuffle

(PHP 4 >= 4.3.0, PHP 5)

str_shuffle -- Randomly shuffles a string

Description

string str_shuffle ( string str)

str_shuffle() shuffles a string. One permutation of all possible is created.

例子 1. str_shuffle() example

<?php
$str
= 'abcdef';
$shuffled = str_shuffle($str);

// This will echo something like: bfdaec
echo $shuffled;
?>

See also shuffle() and rand().




add a note add a note User Contributed Notes
str_shuffle
floweb at yahoo dot com
16-Sep-2003 01:09
this is basically the equivelent to the str_shuffle they use

function str_shuffle($word){
  for($i=0;$i<strlen($word);$i++)
       $array[]=$word[$i];
 
   shuffle($array);
   for($i=0;$i<count($array);$i++)
     $newstring .= $array[$i];
       
   return $newstring;
}

sidenote: wrote this when me and a friend were writing some code and i realized i was using 4.3.0 and he was using 4.2.0 needless to say my code took less lines :)

<str_rot13str_split>
 Last updated: Fri, 22 Jun 2007
view source | feedback | send page | sitemap | aboutus   
Copyright ® 2002-2003 PHPE.NET. All rights reserved
Last updated:2002-11-22