OK, I finally worked everything out!
Here is how my final code went (I've separated and simplified the code here to piece-meal the tasks):
Create the array
$Sponsors=array(
array('Sponsor' => 'Sponsor1', 'Value' => '500'),
array('Sponsor' => 'Sponsor2', 'Value' => '300'),
array('Sponsor' => 'Sponsor3', 'Value' => '300'),
array('Sponsor' => 'Sponsor4', 'Value' => '200'),)
);
Set SponsorTotalCt = the number of sponsors and create a variable to hold the weighted percentage
$SponsorTotalCt = count($Sponsors);
$SponsorWeight = 0;
Get a total value for all the sponsorships
$SponsorTotalAmt = 0;
foreach($Sponsors as $array)
{
$SponsorTotalAmt += $array['Value'];
};
Add the sponsor weight as a percent as another 'field value' in the $Sponsors array
$i = 0; //initialize i
while ($i < $SponsorTotalCt){
foreach($Sponsors as $array)
{
$SponsorWeight = round($Sponsors[$i]['Value']/$SponsorTotalAmt * 100);
$Sponsors[$i]['Weight'] = $SponsorWeight;
};
$i++; // count one up
};
*Note: at this point the $Sponsors 'record listing' would look kind of like this
$Sponsors =
[0] 'Sponsor1','500', 38 (this last is the percent the sponsorship should be weighted)
[1] 'Sponsor2', '300', 23
[2] 'Sponsor3', '300', 23
[3] 'Sponsor4', '200', 15
Notice that the last set of values adds up to 100, or close to it (because of the rounding)*
Create a new array of 100 'records' where each row of the $Sponsors array is repeated the number of times that reflects the percentage. i.e. Sponsor1 values will be repeated in the array 38 times
$newSponsors = array();
$i = 0; //initialize i
while ($i < $SponsorTotalCt){
foreach($Sponsors as $array)
{
$a = array_fill(0, $Sponsors[$i]['Weight'], $Sponsors[$i]);
};
$newSponsors= array_merge($newSponsors,$a);
$i++; // count one up
};
Finally, randomly select 3 keys from the 4 Sponsors, weighted by the value of their Sponsorships
$spot = array_rand($newSponsors,3);
Now I only have to create the code and call the value. YAY!