Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8759793
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T14:53:28+00:00 2026-06-13T14:53:28+00:00

<?php $links = array(); $links[] = ”; //i left this blank so it stays

  • 0
<?php

  $links = array();

  $links[] = ''; //i left this blank so it stays on the current page, problem causer? 
  $links[] = 'http://domain2.com';
  $links[] = 'http://domain3.com';
  $links[] = 'http://domain4.com';

  $link = $links[array_rand($links)];

  header("Location: {$link}");

?>

What I want it to do is either redirect to domain 2, 3, 4 OR stay on the same page its on currently. I want it to be completely random, like the above script.

The above code works on Chrome, however, on FireFox and Internet Explorer it says it is

server is redirecting the request for this address in a way that will never complete

Is there any way to make it work on ALL browsers?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T14:53:29+00:00Added an answer on June 13, 2026 at 2:53 pm
    <?php
    
    $links = array();
    
    $links[] = ''; 
    $links[] = 'http://domain2.com';
    $links[] = 'http://domain3.com';
    $links[] = 'http://domain4.com';
    
    $link   = $links[array_rand($links)];
    
    if ($link !== '') { // Don't pass an empty Location
        header("Location: $link"); // Remove the {}
    }
    
    ?>
    

    Remove the {} and it should be alright. Also, I think it would be best to not pass an empty Location header.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here's what I have on the layout page: <?php $this->widget('zii.widgets.CBreadcrumbs', array( 'links'=>$this->breadcrumbs, 'separator'=>' >
From this query to the Wikipedia API: http://en.wikipedia.org/w/api.php?action=query&prop=links&format=json&plnamespace=0& pllimit=10&titles=List%20of%20television%20programs%20by%20name I get a JSON structure,
My links are like http://www.shinylook.ro/product.php?id=58 and I rewrite them like http://www.shinylook.ro/produs/58/saboti-dama/ using this code:
I have recently learned to create dynamic links via php, but my problem today
I have links on a PHP page where it lists all records from a
Working with PHP Xpath trying to quickly pull certain links within a html page.
I have an iframe tab which holds php page with various links inside (like
I've created a hierarchical main menu with drupal 7, looks like this: http://dl.dropbox.com/u/16019885/Unbenannt.PNG Now,
I'm trying to get an array of all links on a page whose href
I'm in the process of writing a webpage (in PHP, though this problem does

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.