Listing objects with a certain value only once and count them

Hi,

I've been trying to get this done for the last two days but can't seem to get it right.

 

I'm currently listing objects in a widget via elgg_list_entities($options); :

$options = array(
    'type' => 'object',
    'subtype' => 'laud_item',
    'container_guid' => $vars['entity']->owner_guid,
    'limit' => $num,
    'full_view' => FALSE,
    'pagination' => FALSE,
    );

elgg_list_entities($options);

This works perfectly and I was able to display the views the way I wanted...

Now here is my problem: I do have a bunch of objects in there that have the same metadata values. They are being listed twice of course. Is there a simple way to filter them out that they are only listed once? I do not want to delete them since I do in fact need them for something else.

 

So my current listing looks like this:

Item 1

Item 2

Item 3

Item 3

Item 1

Item 1

-------------

I'd like it to look like this:

Item 1 (3 times)

Item 2 (1 time)

Item 3 (2 times)

 

 

Anyway to get that done with elgg_list_entities()  or is there another function that does this?

I know there is elgg_list_entities_from_relationships() but I wasn't able to get it done with that. Is there anyway to do it?

 

Help is much appreciated.

Thanks,

Tino