array_unique showing error Array to string conversion

时光怂恿深爱的人放手 提交于 2019-12-04 22:14:48
Niet the Dark Absol

As per the docs, array_unique compares elements as strings by default. This means your 2D array is being converted to an array of strings (all being "Array" and generating the array-to-string Notice) or which only one can be returned as unique.

Use the SORT_REGULAR flag to compare the elements as they are, but be aware that arrays are only considered equal if they have the same key-value pairs.

Example:

print_r(array_unique($array, SORT_REGULAR));
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!