blob: a1d81903679cf9f3bbe8d030b828b4728ad76d3c [file] [log] [blame]
<?php
function randomSeed (& $companyinfoArray) {
$max = 0;
$arrayCount = count($companyinfoArray);
//This For loop creates the catalog that we Rand into and finds our total wieght ($max)
foreach ($companyinfoArray as $key => $value)
{
$weight = round($value->speed * $value->ranking);
$max += $weight;
$catalog[$key]= $weight;
}
//This loop continues till there are no items left
while (count($catalog))
{
$count = 0;
$rand = rand (1, $max);
// This Loop grabs the item and compares the rand number to its value + count
foreach ($catalog as $key => $value)
{
if ( ($value + $count) >= $rand) // Going in here means we found the right number
{
unset ($catalog[$key]); // Unset removes the entry from the array
$randomized[] = $key; // Add the key of the array to our ordered array
$max -= $value; // Remove the weight of the item from $max
break;
}
else
{
$count += $value; // Value is too low increase count
}
}
}
//$randomized is the randomly ordered order of display
return $randomized;
}
class companyInfo {
var $companyName;
var $companyLogo;
var $companyBlurb;
var $version;
var $projects;
var $linkTo;
var $speed;
var $ranking;
function companyInfo ($_companyName, $_companyLogo, $_version, $_projects, $_companyBlurb, $_linkTo, $_speed, $_ranking = "1") {
$this->companyName = $_companyName;
$this->companyLogo = $_companyLogo;
$this->version = $_version;
$this->companyBlurb = $_companyBlurb;
$this->projects = $_projects;
$this->linkTo = $_linkTo;
$this->speed = $_speed;
$this->ranking = $_ranking;
}
}
?>