How do I delete repeated values in an array and count the number of values in it [duplicate]

-1

My question is quite simple, how do I exclude repeated values from array , for example:

array = banana,morango,laranja,banana,maca

How do I delete 1x banana so that array stays:

array = banana,morango,laranja,maca

And finally, I would like to know which function counts the number of values that have a array ?

    
asked by anonymous 20.12.2016 / 15:27

1 answer

2
$unicos = array_unique($array);
$quantidade = count($unicos);
    
20.12.2016 / 15:29