如何使这些链接在PHP中旋转?
下面是我正在使用的代码 我想能够旋转到用户的随机链接 我希望它在link1.com/link2.com/link3.com之间旋转,而不仅仅是link1.com 我如何修改此代码才能做到这一点 提前谢谢你如何使这些链接在PHP中旋转?,php,Php,下面是我正在使用的代码 我想能够旋转到用户的随机链接 我希望它在link1.com/link2.com/link3.com之间旋转,而不仅仅是link1.com 我如何修改此代码才能做到这一点 提前谢谢你 <?php require_once('geoplugin.class.php'); $geoplugin = new geoPlugin(); $geoplugin->locate(); $geo_region = $geoplugin->
<?php
require_once('geoplugin.class.php');
$geoplugin = new geoPlugin();
$geoplugin->locate();
$geo_region = $geoplugin->region;
switch($geo_region) {
case 'CA':
header('Location: http://www.link1.com');
exit;
default: // exceptions
header('Location: http://www.everyoneelsegoeshere.com');
exit;
}
?>
试试这个:
require_once('geoplugin.class.php');
$geoplugin = new geoPlugin();
$geoplugin->locate();
$geo_region = $geoplugin->region;
$links = array('link1.com','link2.com','link3.com');
switch($geo_region) {
case 'CA':
header('Location: http://'.$links[array_rand($links)]);
exit;
default: // exceptions
header('Location: http://www.everyoneelsegoeshere.com');
exit;
}
非常好,谢谢!我试图投票选出最佳答案,但我的声誉还不够高。到时候,我会回来投票。再次感谢。