Cycle through list of links
Moderator: General Moderators
Cycle through list of links
I would like to cycle through a list of links with PHP. And what I mean is if there are several links (mirrors) to a file and one of the links fails, to move on the list to the next link. Is this possible?
Re: Cycle through list of links
Check out tutorials of a for each loop. You'll need to add all of your links to an array and then cycle them through the loop and act on them inside of the loop.
Alternatively, if you have a variable assigned to each link, you can do use a switch/case statement.
I'm not sure which solution would work best for you.
Alternatively, if you have a variable assigned to each link, you can do use a switch/case statement.
I'm not sure which solution would work best for you.
- superdezign
- DevNet Master
- Posts: 4135
- Joined: Sat Jan 20, 2007 11:06 pm
Re: Cycle through list of links
Define "failing". If this is something that you can check for on the server side, then you'd need to reload the page with a different link upon each failure. If you can check for this on the client side, you could put all of the links in on the server-side, but hide them on the client-side until a failure occurs. Then, expose the next link.opsoyo wrote:[If] one of the links fails, to move on the list to the next link. Is this possible?