I have an example that is only to show what I don’t know how to do. When you call the function, it returns either 1 fruit, or if it rolls a 5, then I want the fruits to increment 1 time for each result it rolls and return an array, possibly going into a max recursion of like, 20 if that makes sense! 🙂
function fruitBasket(&$fruit = array()) {
$dice = rand(1, 5);
switch($dice) {
case 1:
$fruit['watermelon'] = ++$watermelon;
break;
case 2:
$fruit['orange'] = ++$orange;
break;
// etc...
case 5:
for($i = 1; $i <= rand(1, 5); $i++) {
fruitBasket($fruit);
}
break;
}
return $fruit;
}
I’m not sure I understand your question exactly as your description is kind of confusing and I’m unable to add a comment, but from what I do understand: