[英]array_unique ignores 0
I have an array of floats. 我有一系列花车。
When I use array_unique, if I have a 0 value, it's left out of the result. 当我使用array_unique时,如果我有一个0值,它将被排除在结果之外。
Is this correct, or is there a way around this? 这是正确的,还是有办法解决这个问题? What's the proper syntax to make it include 0s.
什么是使它包含0的正确语法。
Thanks in advance! 提前致谢!
The array_unique function typecasts the elements of an array as strings by default before comparison. 在比较之前,array_unique函数默认将数组的元素作为字符串进行类型化。
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 http://php.net/manual/en/function.array-unique.php
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.