matching identical array data

greg's picture

He has: 1,581 posts

Joined: Nov 2005

EDIT: had this problem for a day, searched the net for hours on end, then as soon as I post in here I find the solution Laughing out loud
array_unique()

How do you match all data in an array and only output one of each instant?

example

print_r ($some_var);
displays

array ( data1 [0] => data1 [1] => data1 [2] => different [3] => different [4] => data1 [5] )

how do I script to extract only ONE instant of data1 and different ?

assign to a variable, echo each doesnt really matter I suppose, if I know the function to do it I can work from there

I have scoured the net, and php.net though various functions but cant find anything that does exactly this

cheers