Welcome Guest!
Please login
If you do not have an account yet on The Web Squeeze forums, please Register! It’s FREE and there are many benefits:
- Receive Fast Advice
- Learn Programming Languages
- Get Professional Website Reviews
- Quick Troubleshooting Assistance
|
|
Random Url Selection
This is a discussion on Random Url Selection, within the PHP section. This forum and the thread "Random Url Selection" are both part of the Programming Your Website category.
![]() ![]() |
Jun 1 2008, 03:35 PM
Post
#1
|
|
![]() Rapid Squeezer ![]() ![]() ![]() ![]() Group: Team Leaders Posts: 138 Joined: 14-February 08 From: On the t'interweb Member No.: 46 |
Hi,
I am looking for a way that when someone navigates to a file, that file sends them to one of the four links enclosed in that file randomly. Is this possible? Cheers, Ross -------------------- |
|
|
Jun 1 2008, 05:32 PM
Post
#2
|
|
![]() Rapid Squeezer ![]() ![]() ![]() ![]() Group: Members Posts: 182 Joined: 19-February 08 From: Netherlands Member No.: 172 |
Something like this could do the trick:
CODE <?php $links[] = "http://www.fresh-style.nl"; $links[] = "http://www.thewebsqueeze.com"; $links[] = "http://www.php.net"; $links[] = "http://www.thewebsqueeze.com/forum/PHP-f11/Random-Url-Selection-t1639.html"; $rand = $links[array_rand($links)]; header("location: " . $rand); exit(); ?> There's no check to see if the same value occures twice in a row, so you can be redirected to the same url twice. And ofcourse you can't place data output to the browser before the header command. You can simply add/remove a link by copying a line and changing the url value. Hope it's helpfull. -------------------- fresh-style.nl - small webdesign & development projects |
|
|
Jun 2 2008, 01:16 PM
Post
#3
|
|
![]() Rapid Squeezer ![]() ![]() ![]() ![]() Group: Team Leaders Posts: 138 Joined: 14-February 08 From: On the t'interweb Member No.: 46 |
That's great thanks very much. I will give it a go once the other links are sorted.
Thanks a lot for your help Cheers, Ross -------------------- |
|
|
If you found The Web Squeeze to be helpful, please donate so we can keep this site FREE, FRESH, and fortified with Web Design & Development info!
![]() ![]() |
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:
Similar Topics
| Topic Title | Replies | Topic Starter | Views | Last Action | |||
|---|---|---|---|---|---|---|---|
![]() |
7 | Jason | 245 | 23rd February 2008 - 10:46 AM Last post by: rewake |
|||
![]() |
5 | edd | 139 | 26th March 2008 - 03:37 AM Last post by: c010depunkk |
|||
![]() |
8 | JustinStudios | 174 | 29th March 2008 - 10:29 PM Last post by: JustinStudios |
|||
![]() |
6 | Jason | 259 | 19th May 2008 - 02:00 AM Last post by: Jason |
|||
![]() |
1 | edd | 171 | 3rd July 2008 - 12:42 PM Last post by: Scott |
|||






Jun 1 2008, 03:35 PM







