forked from tilderadio/site
simplify random slogan
This commit is contained in:
parent
54d8680435
commit
e83dcb9f7e
14
index.php
14
index.php
|
@ -3,18 +3,8 @@
|
||||||
<h1><a href="https://tilderadio.org"><img style="width:75px;" src="./logos/tilderadio-green.png">tilderadio.org</a></h1>
|
<h1><a href="https://tilderadio.org"><img style="width:75px;" src="./logos/tilderadio-green.png">tilderadio.org</a></h1>
|
||||||
<h4>
|
<h4>
|
||||||
<?php
|
<?php
|
||||||
$file = "slogans.txt";
|
$slogans = file("slogans.txt");
|
||||||
// Convert the text fle into array and get text of each line in each array index
|
echo $slogans[array_rand($slogans)];
|
||||||
$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;
|
|
||||||
?>
|
?>
|
||||||
</h4>
|
</h4>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue