I want to access and display one value from each of the arrays (which have the same index) using a randomly generated index.
My code:
$userRank = array(
"Nightowl",
"Demon Hunter",
"Shadow Walker",
"Legend"
);
$userLevel = array(
"Level 5",
"Level 10",
"Level 15",
"Level 20",
);
$deck = array();
foreach($userRank as $rank){
foreach($userLevel as $level){
$deck[] = array("level" => $level, "rank" => $rank);
}
}
shuffle($deck);
$getVal = array_shift($deck);
echo $getVal['level'] . ' ' . $getVal['rank'];
The end result of this is that the array retrieves random values from the provided arrays.
e.g. Level 10 Nightowl or Level 20 Shadow Walker
edit: i'm already aware if you use multidimensional array you can just assign each to each other but I want to do it with 2 separate arrays.