$arr_1 = '{
"description": "DESC",
"affter": {
"text": "TEXT"
}
}';
$arr_2 = '{
"name": "Название",
"description": "Описание",
"affter": {
"text": "после",
"icon": "иконка до"
}
}';
$arr_all = '{
"name": "Название",
"description": "DESC",
"affter": {
"text": "TEXT",
"icon": "иконка до"
}
}';
<?php
$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 = [
"name" => $arr_2["name"],
"description" => $arr_1["description"],
"affter" => [
"text" => $arr_1["affter"]["text"],
"icon" => $arr_2["affter"]["icon"],
],
];
$arr_all = json_encode($arr_all, JSON_UNESCAPED_UNICODE|JSON_PRETTY_PRINT);
echo $arr_all;
$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 );