Question

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!

Was it helpful?

Solution

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top