API返回的数据是这样的格式
[{"name":"Agnes ","amount":"40000"},{"name":"John","amount":"35000"},{"name":"Joyce","amount":"50000"},{"name":"Peter","value":"45000"}]
我想重新格式化该输出,使其看起来像这样: Agnes-40000, John-35000, Joyce-50000, Peter-45000 所以,我写了这样的东西,让 $data 代表上面返回的数据;
$new = json_decode($data);
foreach ($new as $key => $jsons) {
foreach($new as $key => $value) {
echo $value;
echo ",";
}
}
但我得到的输出如下: Agnes,40000, John,35000, Joyce,50000, Peter,45000 如何编写 javascript 来显示 Agnes-40000, John-35000, Joyce-50000, Peter-45000 等数据
红颜莎娜
慕的地6264312