Hi, I have a file in which I would like a number of codes to rotate on time based intervals. I would like to include a new file where I can add the codes. So basically for instance I have index.php. In this file I include codes.php. Now I would like to add say 60 codes inside codes.php and they must rotate evenly each month. So each code much display like 12 hours each month. Example: index.php <?php include 'codes.php'; $accountKey = ' rotating key!!!!!!! '; ?> codes.php <?php $key1 = 'nRcEEgie0wXk3MpEQJfCvIeriXPlE7iHUV2zE0NZkgY='; $key2 = 'wbJSp+4pTQCmw6F2y4JPlZlwDIpkIhiN64jTcCf4xxM='; etc ?> Can someone help me out here? Thanks!
You want show first code first 12 hours, then 12 hours - second code? Or show codes randomly, but same numbers of times per month for each code? And small note, you should set your codes as array: <?php $keys = array( 'nRcEEgie0wXk3MpEQJfCvIeriXPlE7iHUV2zE0NZkgY=', 'wbJSp+4pTQCmw6F2y4JPlZlwDIpkIhiN64jTcCf4xxM=', ); ?> PHP:
I want to show the codes randomly yes. And do you mean I have to set them as an array inside the include file?
Easiest way will be to show random code from the array. Number of hits per month will be approximately equal to each other. For example: <?php // codes.php function get_code() { $keys = array( 'code1', 'code2', 'code3', ); return $keys[rand(0, count($keys)-1)]; } ?> PHP: <?php //index.php include 'codes.php'; echo get_code(); ?> PHP:
How should I add echo get_code(); inside $accountKey = 'nRcEEgie0wXk3MpEQJfCvIeriXPlE7iHUV2zE0NZkgY='; Thanks.
$accountKey = ' rotating key is '.get_code().'!!!!!!! '[/COLOR][/FONT][/SIZE][SIZE=3][FONT=courier new][COLOR=#000000] PHP: