From 935f20c019be853eff667a98822dee07de7856bd Mon Sep 17 00:00:00 2001 From: Steffen Lange Date: Thu, 25 Mar 2021 22:43:02 +0100 Subject: [PATCH] Simplify line extraction --- index.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/index.php b/index.php index 522a533..7d58912 100644 --- a/index.php +++ b/index.php @@ -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]; + } } ?>