$arr_1 = '{
"description": "DESC",
"affter": {
"text": "TEXT"
}
}';
$arr_2 = '{
"name": "Название",
"description": "Описание",
"affter": {
"text": "после",
"icon": "иконка до"
}
}';
$arr_1 = json_decode( $arr_1, true );
$arr_2 = json_decode( $arr_2, true );
$arr_all = array_replace_recursive( $arr_2, $arr_1 );
var_dump( $arr_all );
function json_tree_tags_recursive($data, &$result, $path = '')
{
foreach ($data as $key => $value) {
if ($path !== '') {
$result[$path . $key] = $value;
} elseif (!is_array($value)) {
$result[$key] = $value;
}
if (is_array($value)) {
json_tree_tags_recursive($value, $result, $path . $key . '_');
}
}
}
json_tree_tags_recursive($data, $result);
print_r($result);