【发布时间】:2017-06-03 00:20:04
【问题描述】:
我有一个这样的数组
Array
(
[0] => Array
(
[title] => first
[description] => first item
)
[1] => Array
(
[title] => second
[description] => second item
)
)
并使用集合forget() 方法从数组中删除一个项目
$new = collect($arr);
$new->forget(0);
echo json_encode($new->all());
这是上面的json输出
{"1":{"title":"second ","description":"second item"}}
但我期待这样的 json
[{"title":"second ","description":"second item"}]
另外,在应用forget() 方法后如何重新索引上述数组??
【问题讨论】: