Jump to content

[SOLVED] Random doesn't pick a value anymore..


SirChick

Recommended Posts

I have a random array and when i echo the value that the array chooses it seems to be empty..... I'm not sure why.. i purposely only put one choice for testing purposes and it still won't do it.... this is what i have:

 

$PercentageAddOn = array();
			//$PercentageAddOn[] = 2.62;
			//$PercentageAddOn[] = 52421;
			//$PercentageAddOn[] = 51;
			$PercentageAddOn[] = 1.32;
			//$PercentageAddOn[] = 4.72;
			//$PercentageAddOn[] = 9.72;
			//$PercentageAddOn[] = 0.2;
			//$PercentageAddOn[] = 0.72;
			//$PercentageAddOn[] = 0..9;
		$PercentageKey = array_rand($PercentageAddOn);
		$PercentageAddOn = $PercentageResults[$PercentageKey];

 

The result should be $PercentageAddOn[] = 1.32; but when echo'd it doesn't show anything....Any one know why? It did used to work but I don't know why but its decided not to work. =/

$PercentageAddOn = $PercentageResults[$PercentageKey];

 

first you don't have square brackets for $PercentageAddOn

second you seem to be adding an item out of array $PercentageResults to $PercentageAddOn

 

$PercentageResults[1.32] is not a valid aray position.

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.