What are the advantages and disadvantages of storing menu data in a database versus an array in PHP?

Storing menu data in a database allows for easier management and updating of menu items, as well as the ability to easily query and filter the data. However, using an array in PHP can be simpler and more lightweight for smaller menus, without the need for a database connection.

// Storing menu data in a database
// Connect to the database
$conn = new mysqli($servername, $username, $password, $dbname);

// Query the menu items
$sql = "SELECT * FROM menu_items";
$result = $conn->query($sql);

// Fetch and display the menu items
if ($result->num_rows > 0) {
    while($row = $result->fetch_assoc()) {
        echo $row["item_name"] . " - " . $row["price"] . "<br>";
    }
} else {
    echo "No menu items found";
}

$conn->close();