note 93364 added to function.array-pop
| From: | jim203nospamplz at plznospamaol dot com | Date: | Sat, 05 Sep 2009 19:28:16 +0000 |
| Subject: | note 93364 added to function.array-pop | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-160243@lists.php.net to get a copy of this message | ||
Pseudorandom array sort, based on salt input, with the same output every time.
<?php
// sort array based on $SALT;
$SALT = 'a4f1'; // pick any hex
$temparray = $arrayToSort;
$arrayToSort = array();
$startingFileNumber = hexdec($SALT) % count($temparray);
$fileNumber = $startingFileNumber;
$filesDone = 0;
while ($filesDone < count($temparray))
{
// cycle round the array on a number that is not a factor of the count until got all
$theJumpNumber = round(count($temparray)/2) + $startingFileNumber; // use of startingfilenumber
randomizes the jump number
while (count($temparray) % $theJumpNumber == 0)
$theJumpNumber--;
$filesDone++;
$fileNumber = ($fileNumber+$theJumpNumber) % count($temparray);
array_push($arrayToSort,$temparray[$fileNumber]);
}
unset($temparray);
?>
More info at http://www.zyngal.com/blog/
----
Server IP: 208.69.120.35
Probable Submitter: 89.195.73.35
----
Manual Page -- http://www.php.net/manual/en/function.array-pop.php
Edit -- https://master.php.net/note/edit/93364
Del: integrated -- https://master.php.net/note/delete/93364/integrated
Del: useless -- https://master.php.net/note/delete/93364/useless
Del: bad code -- https://master.php.net/note/delete/93364/bad+code
Del: spam -- https://master.php.net/note/delete/93364/spam
Del: non-english -- https://master.php.net/note/delete/93364/non-english
Del: in docs -- https://master.php.net/note/delete/93364/in+docs
Del: other reasons-- https://master.php.net/note/delete/93364
Reject -- https://master.php.net/note/reject/93364
Search -- https://master.php.net/manage/user-notes.php