假设我有一个这样的集合:$collection = [ App\User {name: 'Bob', age: 20}, App\User {name: 'Joe', age: 22}, App\User {name: 'Lisa', age: 20}]我像$collection->groupBy('age'). 我得到这个结果:[ "20" => [ App\User {name: 'Bob', age: 20}, App\User {name: 'Lisa', age: 20}, ], "21" => [ App\User {name: 'Joe', age: 22} ]]我想删除关联键并只使用索引数组,如下所示:[ [ App\User {name: 'Bob', age: 20}, App\User {name: 'Lisa', age: 20}, ], [ App\User {name: 'Joe', age: 22] ]]这可能与 Laravel 收集方法有关吗?在此先感谢您的指点!
1 回答
- 1 回答
- 0 关注
- 191 浏览
添加回答
举报
0/150
提交
取消