我有一个来自 laravel 的 JSON 数组,如下所示:
Illuminate\Support\Collection Object
(
[items:protected] => Array
(
[0] => Array
(
[_id] => MongoDB\BSON\ObjectID Object
(
[oid] => 5a15e52b5bd98b7a0040fac8
)
[UnitPrice] => 18
[UnitsInStock] => 39
)
[1] => Array
(
[_id] => MongoDB\BSON\ObjectID Object
(
[oid] => 5a15e52b5bd98b7a0040fac9
)
[UnitPrice] => 19
[UnitsInStock] => 17
)
[2] => Array
(
[_id] => MongoDB\BSON\ObjectID Object
(
[oid] => 5a15e52b5bd98b7a0040faca
)
[UnitPrice] => 10
[UnitsInStock] => 13
)
)
)
我怎样才能只把UnitPrice
和UnitsInStock
作为一个数组?有没有不使用循环的方法?
我想像这样使用它:
...
->dataset('UnitPrice', [5,20,100,...]) // array's values = [5,20,100,...]
->dataset('UnitsInStock', [52,120,100,...]) // array's values = [52,120,100,...]