Thursday, 12 September 2013

How to randomly pull same index from two arrays?

How to randomly pull same index from two arrays?

My function is outputting what it should. When I run this, all I get is
"It was then that the gods reached out and decided to give the power of to
aid in this quest." How can I make it pick the same index from both arrays
and fill in the variables in the echo?
function gift_giver()
{
$people = array ("$heroname", "$friendname", "$wizardname", "Captain
Rumbeard", "$frogname");
$gifts = array("a magic compass", "the gift of no fear", "all seeing
powers", "more rum", "a delightful lilly pad");
$gift_selector=(rand(0,4));
$gift_recipient=$people[$gift_selector];
$gift_present=$gift[$gift_selector];
echo "It was then that the gods reached out and decided to give
$gift_recipient the power of $gift_present to aid in this
quest.<br/><br/>";
}

No comments:

Post a Comment