PHP Coding Question

nam6641

Supreme Member
Joined
Nov 15, 2008
Messages
1,470
Reaction score
926
i want to set up a php rotator redirect... i tried modifying a code i found on here but it always keeps redirecting to Yah00 and never G00gle or Ask.

any clues from PHP coders?

Code:
<?php
//Add as many links you want
$mylink[] = header( 'Location: http://ask.com' ) ;

$mylink[] = header( 'Location: http://google.com' ) ;

$mylink[] = header( 'Location: http://yahoo.com' ) ;




// this will display the random link
echo $mylink[array_rand($mylink)];
?>
 
Try this
Code:
<?php
$mylink[0] = "http://ask.com";

$mylink[1] = "http://google.com";

$mylink[2] = "http://yahoo.com";
$lenght = count($mylink) - 1;
$i = rand(0, $lenght);
header('Location: '.$mylink[$i]);
?>
or this
Code:
<?php
	$i = rand(0, 2);
	if($i==0){
		header('Location:http://yahoo.com');
	}
	if($i==1){
		header('Location:http://google.com');
	}
	if($i==2){
		header('Location:http://ask.com');
	}
		
?>
 
i tried the 2nd one and it worked perfect. thanks bro.
 
Back
Top