How can PHP arrays be effectively used to store and manipulate energy cost data for different ranks and rarities in a fusion system?

To effectively store and manipulate energy cost data for different ranks and rarities in a fusion system using PHP arrays, you can create a multidimensional array where the keys represent the rank and rarity combinations, and the values represent the energy costs. This allows for easy access and manipulation of the data based on the specific rank and rarity of the fusion.

// Define an array to store energy cost data for different ranks and rarities
$energyCosts = [
    'common' => [
        'rank1' => 10,
        'rank2' => 20,
        'rank3' => 30
    ],
    'rare' => [
        'rank1' => 15,
        'rank2' => 25,
        'rank3' => 35
    ],
    'epic' => [
        'rank1' => 20,
        'rank2' => 30,
        'rank3' => 40
    ]
];

// Access energy cost for a specific rank and rarity
$rank = 'rank2';
$rarity = 'rare';
$energyCost = $energyCosts[$rarity][$rank];
echo "Energy cost for $rarity $rank fusion: $energyCost";