PHP character functions
PHP produces the stochastic string of character the function, below is I in 2 which on-line found about the PHP stochastic string of character function, hoped that everybody liked.
First example this used php shuffle to disrupt the array function
PHP:
<? phpfunction genRandomString($len){ $chars = array ( “a”, “b”, “c”, “d”, “e”, “f”, “g”, “h”, “i”, “j”, “k”, “l”, “m”, “n”, “o”, “p”, “q”, “r”, “s”, “t”, “u”, “v”, “w”, “x”, “y”, “z”, “A”, “B”, “C”, “D”, “E”, “F”, “G”, “H”, “I”, “J”, “K”, “L”, “M”, “N”, “O”, “P”, “Q”, “R”, “S”, “T”, “U”, “V”, “W”, “X”, “Y”, “Z”, “0”, “1”, “2”, “3”, “4”, “5”, “6”, “7”, “8”, “9” ); $charsLen = count($chars) - 1; shuffle($chars); // disrupts the array $output = ""; for ($i=0; $i<$len; $i++) { $output. = $chars [mt_rand (0, $charsLen)]; } return $output; }$str = genRandomString(25);$str. = “<br/>”;$str. = genRandomString(25);$str. = “<br/>”;$str. = genRandomString(25);echo $str;? >
Second demonstration this used the php rand random function
PHP:
<? php/* Generate Password* Length: 8*/$str = “0123456789abcdefghijklmnopqrstuvwxyz”; // output character repertoire $n = 8; // output string length $len = strlen($str)-1;for ($j=0; $j<200; $j++) {for ($i=0; $i<$n; $i++) { $s. = $str[rand(0,$len)]; }echo $s. “<br/>”;$s = "";}? >