- json_decode: documentation ( source)
- print_r: documentation ( source)
- array_replace_recursive: documentation ( source)
- array_walk_recursive: documentation ( source)
<?php
$json = '{"language":"en","education":[{"unit":"e1","language":"en"}],"membership":[{"uei":"21","Uifed":"failed"}]}';
$arrayData = json_decode($json, true);
$replacementData = array('membership' => array(array('Uifed' => 'success')));
$newArrayData = array_replace_recursive($arrayData, $replacementData);
print_r($newArrayData);
$replacementData = array('Uifed' => 'success');
array_walk_recursive($arrayData, function (&$value, $key) use ($replacementData) {
$value = $replacementData[$key] ?? $value;
});
print_r($arrayData);