Hi i have this code which takes lines in a text file puts it in an array and then prints the first array value. Once the user refreshes the screen we move onto the next array element.
I want to put this into a function so i can use it for different text files, but i don't know how to handle the cookies and return the current $iQuoteNum to the cookie outside the function. I've figured i can't have the setcookie function inside the function as i'm getting the headers already sent error?
Any help would be appreciated.
$filename = "advert.txt";
$a_advert = array();
$file = fopen($filename, "r");
$aQuotes = fgets($file, 4096);
$iQuoteNum = $_COOKIE["quotes"];
if($iQuoteNum == "" || $iQuoteNum >= sizeof($aQuotes)-1)
$iQuoteNum = 0;
$banner = $aQuotes[$iQuoteNum];
Pass value from function to cookie
No replies to this topic
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users