我有一个像这样的数组
但是在使用array_unique函数之后,我只剩下了这个:
我在做什么错了吗?
Array
(
[0] => Array
(
[id] => BA
[name] => British Airways
)
[1] => Array
(
[id] => BA
[name] => British Airways
)
[2] => Array
(
[id] => LA
[name] => Lanchile
)
[3] => Array
(
[id] => LA
[name] => Lanchile
)
[4] => Array
(
[id] => BA
[name] => British Airways
)
[5] => Array
(
[id] => BA
[name] => British Airways
)
)
and i want to get
Array
(
[0] => Array
(
[id] => BA
[name] => British Airways
)
[1] => Array
(
[id] => LA
[name] => Lanchile
)
)
但是在使用array_unique函数之后,我只剩下了这个:
Array
(
[0] => Array
(
[id] => BA
[name] => British Airways
)
)
我在做什么错了吗?
array_unique(my_array, SORT_REGULAR)
了吗?这个函数可以去除数组中的重复元素,保留数据类型和键值。 - diegoperini