simplify random slogan

This commit is contained in:
Ben Harris 2020-06-21 12:37:34 -04:00
parent 54d8680435
commit e83dcb9f7e
1 changed files with 2 additions and 12 deletions

View File

@ -3,18 +3,8 @@
<h1><a href="https://tilderadio.org"><img style="width:75px;" src="./logos/tilderadio-green.png">tilderadio.org</a></h1>
<h4>
<?php
$file = "slogans.txt";
// Convert the text fle into array and get text of each line in each array index
$file_arr = file($file);
// Total number of linesin file
$num_lines = count($file_arr);
// Getting the last array index number by subtracting 1 as the array index starts from 0
$last_arr_index = $num_lines - 1;
// Random index number
$rand_index = rand(0, $last_arr_index);
// random text from a line. The line will be a random number within the indexes of the array
$rand_text = $file_arr[$rand_index];
echo $rand_text;
$slogans = file("slogans.txt");
echo $slogans[array_rand($slogans)];
?>
</h4>