What are the potential pitfalls of using if & else loops for game logic in PHP, and how can they be avoided?

Potential pitfalls of using if & else loops for game logic in PHP include code duplication, difficulty in managing complex branching conditions, and reduced readability. To avoid these issues, consider using switch statements instead, which can help organize code more efficiently and make it easier to understand and maintain.

// Using switch statements for game logic in PHP
$playerChoice = "rock";

switch ($playerChoice) {
    case "rock":
        // Handle logic for player choosing rock
        break;
    case "paper":
        // Handle logic for player choosing paper
        break;
    case "scissors":
        // Handle logic for player choosing scissors
        break;
    default:
        // Handle logic for invalid choice
        break;
}