Reputation: 57
Ok so I am trying to make a text appear so something like this
<h1>Text Goes here</h1>
but I wanted that text to be in a text file which would update everyday from a text file which would already have all the text so for example 365 lines of text and this would be using php I have tried it before but I couldnt make it work. Code :
$lines = file("quotes.txt");
$day = date("z");
echo $lines[$day];
Upvotes: 0
Views: 114
Reputation: 1963
If your file contains plain text you will need to convert it to an array before you can get the line you're after. Try this...
$text = file("quotes.txt");
$search = array ("\r\n", "\r");
$text = str_replace($search, "\n", $text);
$array = explode("\n", $text);
$line = date("z");
echo $array[$line];
Also, don't forget it's a leap year this year, you'll need 366 lines of text!
Upvotes: 1