我如何从 php 中的集合中获取值
How can i get the value from collection in php
我有以下格式的数据存储
[{"id":"927","store_id":"63","cover":"Banana.png","name":"Organic Banana / Kela / Keli"}]
我需要获取名称和所有键值对。但不知道如何在 Core PHP 中做到这一点。如果有人帮助它会很棒。谢谢:)
https://www.php.net/manual/en/function.json-decode.php
$json = '[{"id":"927","store_id":"63","cover":"Banana.png","name":"Organic Banana / Kela / Keli"}]';
$json_decoded = json_decode($json, true);
foreach ($json_decoded as $product){
echo($product['name']);
// get others similarly
}
我有以下格式的数据存储
[{"id":"927","store_id":"63","cover":"Banana.png","name":"Organic Banana / Kela / Keli"}]
我需要获取名称和所有键值对。但不知道如何在 Core PHP 中做到这一点。如果有人帮助它会很棒。谢谢:)
https://www.php.net/manual/en/function.json-decode.php
$json = '[{"id":"927","store_id":"63","cover":"Banana.png","name":"Organic Banana / Kela / Keli"}]';
$json_decoded = json_decode($json, true);
foreach ($json_decoded as $product){
echo($product['name']);
// get others similarly
}