<?php
function rand_chars($c, $l, $u = FALSE) {
if (!$u) for ($s = '', $i = 0, $z = strlen($c)-1; $i < $l; $x = rand(0,$z), $s .= $c{$x}, $i++);
else for ($i = 0, $z = strlen($c)-1, $s = $c{rand(0,$z)}, $i = 1; $i != $l; $x = rand(0,$z), $s .= $c{$x}, $s = ($s{$i} == $s{$i-1} ? substr($s,0,-1) : $s), $i=strlen($s));
return $s;
}
?>
string $c is the string of characters to use.
integer $l is how long you want the string to be.
boolean $u is whether or not a character can appear beside itself.
Examples:
rand_chars("ABCEDFG", 2);
rand_chars("ABCEDFG", 2, TRUE);
<?php
function rand_chars($c, $l, $u = FALSE) {
if (!$u) for ($s = '', $i = 0, $z = strlen($c)-1; $i < $l; $x = rand(0,$z), $s .= $c{$x}, $i++);
else for ($i = 0, $z = strlen($c)-1, $s = $c{rand(0,$z)}, $i = 1; $i != $l; $x = rand(0,$z), $s .= $c{$x}, $s = ($s{$i} == $s{$i-1} ? substr($s,0,-1) : $s), $i=strlen($s));
return $s;
}
function print_list($num, $seperator)
{
$I = 0;
for ($I = 0; $I < $num; $I++)
{
echo rand_chars("abcdefghijklmnopqrstuvwxyz", 2).$seperator;
}
}
print_list(100,"<br />");
?>
It didnt work.
Parse error: syntax error, unexpected T_LNUMBER, expecting '&' or T_VARIABLE in /home/site/public_html/script.php on line 8
I dont want a result repeated.
I generated 10000
and sg was repeated more than 5 times.
<?php
$how_many_times = 10;
$group_size = 2;
$letters = str_split("abcdefghijklmnopqrstuvwxyz");
while($i++ <= $how_many_times) {
shuffle($letters);
print implode("", array_shift(array_chunk($letters, $group_size))) . "<br>";
}
?>
More specific than what?If anybody of U have some more specific codes, expect those which are enlisted here, do give me a PM. I m interested in getting those.