I'm using array_unique
to remove the duplicate values but it returns an object format.
我正在使用array_unique删除重复的值,但它返回一个对象格式。
$event = array_unique($array_event);
output as
{"0":{"title":"new","description":"hai"},"4":null}
Excepted output:
[{"title":"new","description":"hai"},null}]
Can anyone help with this issue?
有人可以帮忙解决这个问题吗?
1 个解决方案
#1
1
You shoud reindex result before json_encode
你在json_encode之前重新调整结果
$event = array_values(array_unique($array_event));
#1
1
You shoud reindex result before json_encode
你在json_encode之前重新调整结果
$event = array_values(array_unique($array_event));