Example #1
0
function song()
{
    //Maximale Zeilenanzahl pro Strophe
    $maximale_Zeilenanzahl = 4;
    //Maximale Strophenanzahl pro Song
    $maximale_Strophenanzahl = 5;
    //Songtext-Variable
    $songtext = "";
    //Minimal 2 Strophen, maximale Anzahl in Variablen
    $strophenanzahl = rand(2, $maximale_Strophenanzahl);
    //Muster für Zeilenanzahl festlegen
    //$muster = 1; Immer 3
    //$muster = 2; Abwechselnd 4 und 6
    $muster = rand(1, 2);
    //Für jede Strophe
    for ($i = 1; $i <= $strophenanzahl; $i++) {
        if ($muster == 1) {
            $songtext .= "<br><br>" . strophe(3);
        } else {
            if ($i % 2 == 0) {
                $songtext .= "<br><br>" . strophe(4);
            } else {
                $songtext .= "<br><br>" . strophe(6);
            }
        }
    }
    //Songtext wird schließlich zurückgegeben
    return $songtext;
}
Example #2
0
echo "<b>Anzahl Zeilen:</b> " . implode(", ", $zeilenAnzahl) . "<br />";
$silbenAnzahl = silbenanzahl($strophenAnzahl);
echo "<b>Anzahl Silben:</b> " . implode(", ", $silbenAnzahl) . "<br />";
#for($i = 0; $i < sizeof($zeilenAnzahl); $i++){
#	$fax = kleinsteFaktoren($zeilenAnzahl[$i] - 1);
#	echo "<b>Faktoren " . ($i + 1) . ":</b> " . implode(", ",$fax) . "<br />";
#}
$silben = silben($vokale, $konsonanten, $zeilenAnzahl);
echo "<br />";
for ($i = 0; $i < sizeof($zeilenAnzahl); $i++) {
    echo "<b>Silben in Strophe " . ($i + 1) . ":</b> " . implode(", ", $silben[$i]) . "<br />";
}
echo "<br />";
$strophen = array();
for ($i = 0; $i < $strophenAnzahl; $i++) {
    array_push($strophen, stropheToString(strophe($zeilenAnzahl[$i], $silbenAnzahl[$i], $silben[$i])));
}
$text = "";
$text = "<pre>";
for ($i = 0; $i < sizeof($strophen); $i++) {
    $text .= "<i>[Strophe " . ($i + 1) . "]</i> <br />" . $strophen[$i] . "<br />";
}
$text .= "</pre>";
echo $text;
?>
	</div>
	</body>
</html>

<!-- 
TODO: