Everything was going smooth on my random loot generator, until this.
Basically I am trying to get multiple random stats from this array
Code: Select all
$itemstats = array("speed","power","melee","meleedef","health","agility");Code: Select all
function Select_Random_Indices($itemstats, $count = 2)
{
if($count > 0)
{
if($count == 1)
{
$result = array(array_rand($itemstats, $count));
}
else
{
$result = array_rand($itemstats, $count);
}
}
else
{
$result = array();
}
return $result;
}
function Select_Random_Entries($itemstats, $count = 2)
{
$result = array();
$index_array = Select_Random_Indices($itemstats, $count);
foreach($index_array as $index)
{
$result[$index] = $itemstats[$index];
}
return $result;
}