所以,我有一些看起来像这样的JSON数据:
{
"Table1":[
{
"CURRENCY_FLAG":"EUR",
"TRADE_DATE":"2015-10-15",
"DELIVERY_DATE":"2015-10-15",
"DELIVERY_HOUR":"7",
"DELIVERY_INTERVAL":"1",
"RUN_TYPE":"EA",
"SMP":"35.370",
"LAMBDA":"35.370",
"SYSTEM_LOAD":"3164.611",
"CMS_TIME_STAMP":"2015-10-14T10:03:09+01:00"
},
{
"CURRENCY_FLAG":"GBP",
"TRADE_DATE":"2015-10-15",
"DELIVERY_DATE":"2015-10-15",
"DELIVERY_HOUR":"7",
"DELIVERY_INTERVAL":"1",
"RUN_TYPE":"EA",
"SMP":"26.460",
"LAMBDA":"26.460",
"SYSTEM_LOAD":"3164.611",
"CMS_TIME_STAMP":"2015-10-14T10:03:09+01:00"
}... etc
我在PHP方面非常基础,但是已经使用CURL获取了这些数据,现在我想迭代这些数据并使用" GBP"删除每个节点。价值为" CURRENCY_FLAG"并且只需依靠" EUR"登录。
有人能指出我使用PHP解析这个问题的正确方向吗?
谢谢!
答案 0 :(得分:0)
使用json_decode()
//decode json string
$result = json_decode($curl_result, true);
$final_result = [];
foreach($result['Table1'] as $key => $value){
if($value['CURRENCY_FLAG'] != 'GBP'){ //exclude currency flag with GBP
$final_result[] = $value;
}
}
print '<pre>';
print_r($final_result);
print '</pre>';