我有 JSON 数据,想通过键更新值。
JSON:
{
"language":"en",
"education":[
{
"unit":"e1",
"language":"en"
}
],
"membership":[
{
"uei":"21",
"Uifed":"failed"
}
]
}
我想将“失败”的值更改uifed为“成功”。
我做了什么?
$json = '{"language":"en","education":[{"unit":"e1","language":"en"}],"membership":[{"uei":"21","Uifed":"failed"}]}';
$arrayData = json_decode($json, true);
$replacementData = array('Uifed' => 'success');
$newArrayData = array_replace_recursive($arrayData, $replacementData);
echo var_dump($newArrayData);
结果:
NULL
我怎样才能做到这一点?
鸿蒙传说
慕标琳琳