array_unique showing error Array to string conversion array_unique showing error Array to string conversion codeigniter codeigniter

array_unique showing error Array to string conversion


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));