phpbar.de logo

Mailinglisten-Archive

Re: [php] Aussprechbare Kunstwörter

Re: [php] Aussprechbare Kunstwörter

Lars Brinkmann brinkmann.lars at gmail.com
Mit Aug 24 13:04:46 CEST 2005


Hallo Reinhold,

Das folgende Script erzeugt Dir $NumberOfVouchers Kunstwörter nach dem
Muster Vokal+Konsonant ohne doppelte Wörter zu erzeugen:

$NumberOfVouchers = 400;		
$LengthOfVoucherCode = 4;		//	will be multiplied with 2

$conso=array("b","c","d","f","g","h","j","k","l","m","n","p","r","s","t","v","w","x","y","z");
$vocal=array("a","e","i","o","u");

$voucher = array();

for ($i=0; $i < $NumberOfVouchers; $i++)
{
	$phrase = "";
	srand ((double)microtime()*1000000);
	for($f=1; $f <= $LengthOfVoucherCode; $f++)
	{
		$phrase.=$conso[rand(0,19)];
		$phrase.=$vocal[rand(0,4)];
	}
	
	if ( !in_array($phrase, $voucher) )
	{
		$voucher[] = $phrase;
	} else {
		$i--;
	}
}

Viele Grüßem Lars Brinkmann

php::bar PHP Wiki   -   Listenarchive