Jump to content

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.

 

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.