lets say I have an external text file .txt with the following A1 A2 B1 B2 C1 C2 .. .. .. And I have multiple php pages. How would I fetch A1 on one page and A2 on another page? And then when you refresh the pages it fetches some other random pair like R1 R2? Is there a way to do this?
actually I have a simpler question regarding pairs on one page this script keeps giving me an error. I'm trying to echo both array values and it wont work <? $array = array('eggs', 'bacon', 'football', 'baseball', 'ford', 'toyota'); $rand_index = mt_rand(0, count($array) / 2 - 1) * 2; echo $array[$rand_index] . " <br> " . $array[$rand_index + 1]; ?> <?php echo "$array[$rand_index]"; ?><?php echo "$array[$rand_index+1]"; ?> PHP:
The code works fine when I try it, except for this part: <?php echo "$array[$rand_index+1]"; ?> PHP: Addition won't be evaluated like that in a string. Get rid of the double quotes. <? $array = array('eggs', 'bacon', 'football', 'baseball', 'ford', 'toyota'); $rand_index = mt_rand(0, count($array) / 2 - 1) * 2; echo $array[$rand_index] . " <br> " . $array[$rand_index + 1]; ?> <?php echo $array[$rand_index]; ?><?php echo $array[$rand_index+1]; ?> PHP:
off the top of my head: you need a queue table with pairs that can be fetched at a given time along with their fetch status.