note 93474 deleted from function.crc32 by danbrown
| From: | danbrown@php.net | Date: | Fri, 11 Sep 2009 15:37:12 +0000 |
| Subject: | note 93474 deleted from function.crc32 by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-160461@lists.php.net to get a copy of this message | ||
Note Submitter: vova at 77xy dot net
----
You can use crc32 as pseudorandom generator. For example you want to make only one related link per
page but you have several options. You could pregenerate random list like
page1 => link1
page2 => link2
page3 => link1
or use crc32 to create randomness on the fly
<?
$links = array(
'http://blackjackdoc.com',
'http://roulettedoc.com',
'http://slotsdoc.com',
);
$randomIndex = crc32(__FILE__) % count($links);
$randomLink = $links[$randomIndex];
?>
And if you refresh the page $randomLink will remain the same.