Simplify line extraction

This commit is contained in:
Steffen Lange 2021-03-25 22:43:02 +01:00
parent 3ce2b0a43a
commit 935f20c019

View file

@ -6,10 +6,11 @@
*/
header('Content-Type: text/plain');
if ($s = file_get_contents(__DIR__ . '/flachwitze.txt')) {
$a = explode("\n", $s);
if (($c = count($a)) > 1)
echo $a[mt_rand(0, $c - 1)] . "\n";
if ($f = file(__DIR__ . '/flachwitze.txt')) {
if (($c = count($f)) > 1) {
$r = mt_rand(0, $c - 1);
echo $f[$r];
}
}
?>