Random-Name-Script

Seite 1 von 1 - Forum: Coding Stuff auf overclockers.at

URL: https://www.overclockers.at/coding-stuff/random-name-script_159095/page_1 - zur Vollversion wechseln!


Fabian1983 schrieb am 24.02.2006 um 16:07

Hallo!

Tja, da bin ich schon wieder! :D
Diesmal hätte ich folge Bitte:
Kann mir jemand ein Script schreiben, dass mir zufällige "Wörter" ausgibt, die 3 Zeichen lang sind, und die trotzdem noch in der deutschen Sprache auszusprechen sind ? Was ich damit meine ist, dass Wörter wie "RSO" garnicht erst zustande kommen, also keine 2 Konsonanten am Anfang. 2 Konsonanten am Schluss funktionieren ja in der Regel (kommt drauf an welche, aber so pingelig will ich nicht sein).
Ergebnis sollten einfach solche Wörter wie "PAX", "MON", "RIL" usw sein - ist schon klar, dass nicht alle so schön ausschauen, aber selektieren kann ich ja dann von "Hand". :)

Ich hoff ich hab mich verständlich ausgedrückt. :D

TIA :)

MfG, Fabsko


nr1 schrieb am 24.02.2006 um 16:14

http://www.webmaster-resource.de/on...omain-namen.php


moidaschl schrieb am 24.02.2006 um 16:19

in welcher sprache willst dus haben? also im web benutzbar oder daheim als app.

is keine hexerei :)


Fabian1983 schrieb am 24.02.2006 um 16:20

Ist mir völlig egal. :)
Ich bräucht's nur für Namensanregungen, aber bei dem Link, den mir Kurtm gibt, kommen Namen wie "ZGV" und andere unaussprechliche raus.

#edit#

Am Besten wäre natürlich die Abfolge Konsonant Vokal Konsonant.

#edit2#

Nach langer Überlegung, bin ich zu dem Schluss gekommen, es soll nach dem Schema "Konsonant" "Vokal" "Konsonant" sein


raitiss schrieb am 25.02.2006 um 10:15

So ein script ist eigentlich sehr leicht in php, wenn du willst mach ich es fur dich.


raitiss schrieb am 25.02.2006 um 10:21

<html>
<head>
<title>Document Title</title>
</head>
<body>
<?php

$buch1 = array("d", "g", "d", "w", "r", "q", "x", "g", "y", "p", "l", "k", "n", "m", "b", "z", "y");
$buch2 = array("a", "e", "u", "i", "o");
$buch3 = array("d", "g", "d", "w", "r", "q", "x", "g", "y", "p", "l", "k", "n", "m", "b", "z", "y");
$rand1 = rand(0, 16);
$rand2 = rand(0, 4);
$rand3 = rand(0, 4);
echo $buch1[$rand1] . $buch2[$rand2] . $buch3[$rand3];
?>
</body>


moidaschl schrieb am 25.02.2006 um 13:42

Code: PHP
function generate_word() {
		
		// Initialize the random values
		srand();
	
		// create the arrays	
		$consonants = array("b", "c", "d", "f", "g", "h", "j", "k", "l", "m", "n", "p", "q", "r", "s", "t", "v", "w", "x", "y", "z");
		$vowels = array("a", "e", "i", "o", "u");
	
		// Count the elements
		$cons_count = count($consonants);
		$vow_count = count($vowels);
	
		// Generate the Characters
		$random_value = rand(0, $cons_count-1);	
		$first_char = $consonants[$random_value];
	
		$random_value = rand(0, $vow_count-1);
		$second_char = $vowels[$random_value];
	
		$random_value = rand(0, $cons_count-1);
		$third_char = $consonants[$random_value];

		$word = $first_char.$second_char.$third_char;
		
		return $word;
}


for($loopcount = 0; $loopcount < 50; $loopcount++) {
	
		echo generate_word();
		echo "<br />";
	
}


Fabian1983 schrieb am 25.02.2006 um 13:47

Dankeschön, funktioniert. :)


raitiss schrieb am 25.02.2006 um 14:12

geht noch kurzer:


Code: PHP
$buch1 = array("b", "c", "d", "f", "g", "h", "j", "k", "l", "m", "n", "p", "q", "r", "s", "t", "v", "w", "x", "y", "z");
$buch2 = array("a", "e", "u", "i", "o");
$rand1 = rand(0, 20);
$rand2 = rand(0, 4);
$rand3 = rand(0, 20);
// dein replay
echo $buch1[$rand1] . $buch2[$rand2] . $buch1[$rand3];


moidaschl schrieb am 26.02.2006 um 15:25

er brauchts aber 50x ausgegeben, deswegen die schleife. und die funktion wegen der übersichtlichkeit :D


raitiss schrieb am 26.02.2006 um 16:27

aso, dann ist es verstandlich :D




overclockers.at v4.thecommunity
© all rights reserved by overclockers.at 2000-2025