php转到随机链接?
基本上,我正在尝试创建一个random.php页面,如果有人访问它,它会将他们重定向到我想要的特定链接,并且每次他们访问random.php时,都会出现一个不同的链接,例如php转到随机链接?,php,random,Php,Random,基本上,我正在尝试创建一个random.php页面,如果有人访问它,它会将他们重定向到我想要的特定链接,并且每次他们访问random.php时,都会出现一个不同的链接,例如 $urls = array('http://gamingwebsite.com/xlnc', 'http://gamingwebsite.com/xln8', 'http://gamingwebsite.com/xln5', 'http://gamingwebsite.com/xln4', 'http://gamingwe
$urls = array('http://gamingwebsite.com/xlnc', 'http://gamingwebsite.com/xln8', 'http://gamingwebsite.com/xln5', 'http://gamingwebsite.com/xln4',
'http://gamingwebsite.com/xlmv', 'http://gamingwebsite.com/xlms', 'http://gamingwebsite.com/xllz', 'http://gamingwebsite.com/xllp', 'http://gamingwebsite.com/xllj',
'http://gamingwebsite.com/xlle', 'http://gamingwebsite.com/xll9', 'http://gamingwebsite.com/xll5', 'http://gamingwebsite.com/xlks', 'http://gamingwebsite.com/xlkl',
'http://gamingwebsite.com/xlke', 'http://gamingwebsite.com/xlk4', 'http://gamingwebsite.com/xljv', 'http://gamingwebsite.com/xlje', 'http://gamingwebsite.com/xlj9',
'http://gamingwebsite.com/xlj1', 'http://gamingwebsite.com/xjxu', 'http://gamingwebsite.com/xjxd', 'http://gamingwebsite.com/xjx4', 'http://gamingwebsite.com/xjwz',
'http://gamingwebsite.com/xjw1', 'http://gamingwebsite.com/xjup', 'http://gamingwebsite.com/xjtz', 'http://gamingwebsite.com/xjtt', 'http://gamingwebsite.com/xjtn',
'http://gamingwebsite.com/xjrh', 'http://gamingwebsite.com/xjrd', 'http://gamingwebsite.com/xjr3', 'http://gamingwebsite.com/xj1z', 'http://gamingwebsite.com/xizx',
'http://gamingwebsite.com/xizf', ' http://gamingwebsite.com/x3jx', 'http://gamingwebsite.com/x3jp');
这就是我所做的事情,我怎样才能让每次有人访问random.php时,它都会将他们重定向到其中一个链接??多种方式。一个简单的方法是使用和的组合 或使用
多种方式。一个简单的方法是使用和的组合 或使用 简单。只需使用洗牌数组,然后从新随机数组的顶部抓取第一项,并通过以下方式设置一个新的
位置
:
简单。只需使用洗牌数组,然后从新随机数组的顶部抓取第一项,并通过以下方式设置一个新的位置
:
那么,你有一个数组?请注意,如果您的所有链接都以
http://gamingwebsite.com/
不用麻烦将它们添加到数组中。那么,您有一个数组了吗?请注意,如果您的所有链接都以http://gamingwebsite.com/
不要费心将它们添加到阵列中。echo
如何将任何人重定向到任何地方?它不会。。。我现在要在我的答案中加上这一点,echo
如何将任何人重定向到任何地方?它不会。。。“我现在要在我的回答中加上这一点,这是一个非常好的解决方案,”杰克·古尔德说。“这是一个很好的解决方案,”杰克·古尔德说。
header('Location:'. $urls[rand(0, (count($urls)-1))]);
header('Location:'. $urls[array_rand($urls, 1)]);
shuffle($urls);
header('Location: ' . $urls[0]);