Different visitors display different content. the access content of the same visitor remains unchanged in the future, except for clearing the cache. For example
1. there are five content A, B, C, D, and E, one of which will be displayed in one or more locations on the webpage.
2. after the first visitor visits the webpage, he will see content A. When the visitor opens the webpage again, he will see content A unless he clears the browser cache.
3. after the second visitor visits the webpage, he will see B's content. when the visitor opens the webpage again, he will see B's content unless he clears the browser cache.
4 ,...
5. after the sixth visitor visits the webpage, he will see the content of A. When the visitor opens the webpage again, he will see content A unless he clears the browser cache.
6. after the seventh visitor visits the webpage, he will see B's content. when the visitor opens the webpage again, he will see B's content unless he clears the browser cache.
Such as loops
It is equivalent to getting one visitor from 5 items in order to show the visitor. After 5 items are retrieved, they are recycled.
How to write the code for this function?
Reply to discussion (solution)
Save using cookies
$ Arr = array ('A', 'B', 'C', 'D', 'E'); $ file = 'data. log'; // Obtain the page that has not been displayed. if all pages are displayed, the value if (file_exists ($ file) {$ data = json_decode (file_get_contents ($ file) is assigned again ), true); if (! $ Data) {$ data = $ arr ;}} else {$ data = $ arr;} // determines whether the user has accessed the service. if the user has accessed the service, the last access result is displayed, otherwise, extract the previous page and write the user cookiesif (isset ($ _ COOKIE ['show']) {$ result = $ _ COOKIE ['show'];} else {$ result = array_splice ($ data, 3600); $ result = array_pop ($ result); setcookie ('show', $ result, time () + ); file_put_contents ($ file, json_encode ($ data), true);} echo $ result;