-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
main.elm: auch unverschlüsselte Buchstaben auf beiden Zeilen zeigen
satz.php: erste funktionsfähige Version
- Loading branch information
Christian Bläul
committed
Oct 10, 2016
1 parent
49980e9
commit 0c4e696
Showing
2 changed files
with
17 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,15 @@ | ||
<?php | ||
$sText = join(' ', array_map(function($input) { | ||
return preg_replace("/([a-z])- +/", "$1", $input); | ||
}, file('Michael Ende - Der Wunschpunsch.txt'))); | ||
|
||
$sText = str_replace(array("\n", "\r"), "", $sText); | ||
|
||
$aSaetze = explode(".", $sText); | ||
$iSatz = rand(0, count($aSaetze) - 1); | ||
|
||
$sSatz = ''; | ||
while(strlen($sSatz) < 150) $sSatz .= $aSaetze[$iSatz++] . "."; | ||
|
||
header('Access-Control-Allow-Origin: *'); | ||
echo json_encode(array('echterSatz' => 'Zufall')); | ||
echo json_encode(array('anzahlSaetze' => count($aSaetze), 'aktuellerSatzIndex'=> $iSatz, 'echterSatz' => trim(str_replace(" ", " ", $sSatz)))); |