cromagnon Posted April 4, 2013 Share Posted April 4, 2013 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! Quote Link to comment https://forums.phpfreaks.com/topic/276539-make-a-triple-split-test/ Share on other sites More sharing options...
Psycho Posted April 4, 2013 Share Posted April 4, 2013 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; } Quote Link to comment https://forums.phpfreaks.com/topic/276539-make-a-triple-split-test/#findComment-1422943 Share on other sites More sharing options...
cromagnon Posted April 4, 2013 Author Share Posted April 4, 2013 Thank you so much!!! About the random number from 1 to 100... I really dont know :-) Quote Link to comment https://forums.phpfreaks.com/topic/276539-make-a-triple-split-test/#findComment-1422947 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.