Jump to content

Make a triple split-test?


cromagnon

Recommended Posts

Hi guys

 

I am very bad at php :-(

 

Now I like to run a triple split-test between 3 different websites.

 

At the moment I only do a duo splittest, and it looks like this:

 

 

if(rand(1, 100) > 50) {
header("Location: http://www.example1.com");
else {
header("Location: http://www.example2.com");
}
 
How can I ad more than 2 redirects to this test? I have to call the the rand-value something, right?
 
Let me know. THANKS alot!
 
 
Link to comment
https://forums.phpfreaks.com/topic/276539-make-a-triple-split-test/
Share on other sites

I have no idea why you would generate a random number from 1 to 100 and then check for the value >50. Why not just do a random number of 1 or 2.

 

Anyway, you could do for any number of options in this manner

 

$test = rand(1, 4);  //Where 4 is the max number of options
switch($test)
{
  case 1:
    header("Location: http://www.example1.com");
    break;
  case 2:
    header("Location: http://www.example2.com");
    break;
  case 3:
    header("Location: http://www.example3.com");
    break;
  case 4:
    header("Location: http://www.example4.com");
    break;
}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.