What are some best practices for preventing duplicate sponsors from appearing in a PHP event list?

To prevent duplicate sponsors from appearing in a PHP event list, we can maintain a list of unique sponsors and check against this list before adding a new sponsor. This can be achieved by using an array to store the sponsors and checking if a sponsor already exists before adding them to the list.

<?php

// Array to store unique sponsors
$uniqueSponsors = [];

// Function to add sponsor to list if it doesn't already exist
function addSponsor($sponsor) {
    global $uniqueSponsors;
    
    if (!in_array($sponsor, $uniqueSponsors)) {
        $uniqueSponsors[] = $sponsor;
    }
}

// Example usage
addSponsor("Sponsor A");
addSponsor("Sponsor B");
addSponsor("Sponsor A");

print_r($uniqueSponsors);

?>