M2com
11-19-2014, 05:46 AM
Hi!
I've been racking my brain to find a way to do this but with no luck.
I have a string that contains items with corresponding percentages:
$string="item1.20|item2.60|item3.20";
I need to explode this string twice and put in an array so that I can have the array look like this:
$items=array("item1" => "20", etc...)
Then I will have the script generate a random number between 1 and 100 and if that number determines the item that is chosen based on its percentage value, it saves that value as another final variable.
Does anyone have any idea how I can do this?
Thanks a ton in advanced,
M2com
I've been racking my brain to find a way to do this but with no luck.
I have a string that contains items with corresponding percentages:
$string="item1.20|item2.60|item3.20";
I need to explode this string twice and put in an array so that I can have the array look like this:
$items=array("item1" => "20", etc...)
Then I will have the script generate a random number between 1 and 100 and if that number determines the item that is chosen based on its percentage value, it saves that value as another final variable.
Does anyone have any idea how I can do this?
Thanks a ton in advanced,
M2com