Pergunta

I have an array of floats.

When I use array_unique, if I have a 0 value, it's left out of the result.

Is this correct, or is there a way around this? What's the proper syntax to make it include 0s.

Thanks in advance!

Foi útil?

Solução

The array_unique function typecasts the elements of an array as strings by default before comparison.

You might want to try:

array_unique($array, SORT_NUMERIC);

or

array_unique($array, SORT_REGULAR);

http://php.net/manual/en/function.array-unique.php

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top