I have wrote a simple algorithm to only store the first occurrence of a name in my array of artists. I am not concerned with the artist ID. The algorithm works fine but I am worried about performance. Does anybody see a simpler way to write this that would also improve performance if the $performers array was say 200 artists?
$performers = array(
array('id' => '12','name' => 'Grouplove'),
array('id' => '24','name' => 'Grouplove'),
array('id' => '43','name' => 'Coldplay')
);
$tmp = array();
foreach($performers as $performer)
{
$count = 0;
foreach($tmp as $test)
{
if($performer['name'] == $test['name'])
{
$count++;
}
}
if(!$count)
{
$tmp[] = $performer;
}
}