note 93474 added to function.crc32
| From: | vova at 77xy dot net | Date: | Fri, 11 Sep 2009 14:36:19 +0000 |
| Subject: | note 93474 added to function.crc32 | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-160459@lists.php.net to get a copy of this message | ||
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.
----
Server IP: 208.69.120.35
Probable Submitter: 213.227.201.151
----
Manual Page -- http://www.php.net/manual/en/function.crc32.php
Edit -- https://master.php.net/note/edit/93474
Del: integrated -- https://master.php.net/note/delete/93474/integrated
Del: useless -- https://master.php.net/note/delete/93474/useless
Del: bad code -- https://master.php.net/note/delete/93474/bad+code
Del: spam -- https://master.php.net/note/delete/93474/spam
Del: non-english -- https://master.php.net/note/delete/93474/non-english
Del: in docs -- https://master.php.net/note/delete/93474/in+docs
Del: other reasons-- https://master.php.net/note/delete/93474
Reject -- https://master.php.net/note/reject/93474
Search -- https://master.php.net/manage/user-notes.php