How can PHP be used to store the outcomes of a slot machine game?

To store the outcomes of a slot machine game in PHP, you can use an array to hold the results of each spin. Each spin can be represented as an array with the symbols or numbers that appear on the slot machine reels. You can then store each spin result array in another array to keep track of all the spins.

<?php

// Simulate a slot machine game with 3 reels
$reels = array('cherry', 'lemon', 'orange', 'plum', 'bell', 'bar');

// Array to store the outcomes of each spin
$spinResults = array();

// Spin the reels and store the outcomes
for ($i = 0; $i < 3; $i++) {
    $randomIndex = array_rand($reels);
    $spinResults[] = $reels[$randomIndex];
}

// Output the results of each spin
foreach ($spinResults as $index => $result) {
    echo "Spin " . ($index + 1) . ": " . $result . "\n";
}

?>