如何将文件的内容传输到集合
文件内容test.txt
[
{"nmId":40699165,"price":924,"discount":0,"promoCode":0},
{"nmId":40384610,"price":4155,"discount":0,"promoCode":0}
]
我这样理解
$contents = Storage::get('test.txt');
我想在输出视图中获得一个集合
[
['nmId' => '40699165', 'price' => 924, 'discount' => 0, 'promoCode' => 0],
['nmId' => '40384610', 'price' => 4155, 'discount' => 0, 'promoCode' => 0],
]
1条答案
按热度按时间j1dl9f461#
假设文件格式正确,我将使用json_decode()函数。
如果你想要一个laravel系列