1

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!

1 Answers1

4

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

Stegrex
  • 4,004
  • 1
  • 17
  • 19
  • SORT_NUMERIC did it. Must be my PHP version or server or something... Thank-you very much for your help! –  Nov 12 '12 at 01:24