Say you have a file that contains an array with a time and a code like this:
{"TIME":"0410","ARRIVAL":"AAA"}
{"TIME":"0600","ARRIVAL":"BBB"}
{"TIME":"0600","ARRIVAL":"CCC"}
{"TIME":"0600","ARRIVAL":"DDD"}
I need to create something that rotates the url using the code from the array based on the time. The time function is no problem but how would I be changing(rotating) the url of a page with the codes from the array?
I think you want to know how to redirect the user to different urls.
You can either do that with JavaScript:
or the same with standard html redirect:
The
content=30in the latter example means that it refreshes the page after 30 seconds to re-execute your check-function and change the URL appropriately.Assuming you already built that checking function for the time difference, just put this code where it is appropriate!
To iterate through the different values on page load you can use
[array_search()][1]and increase the array-key on the output!That way you search for the value in the URL, which returns you the key of the array it is in. Then you increase the key by one. If this key doesn’t exist, it’ll start on the first position again.