function insertData($arr, $names, $path) {
$pathArr = explode('.', $path);
$lastKey = array_pop($pathArr);
foreach ($names as $lang => $value) {
$branch = &$arr[$lang];
foreach($pathArr as $pathPart) {
if(!isset($branch[$pathPart])) {
$branch = null;
break;
}
$branch = &$branch[$pathPart];
}
if(!$branch) continue;
if($lastKey === 'goods') {
if(!isset($branch['goods'])) $branch['goods'] = [];
$branch['goods'][] = $value;
} else if (!isset($branch[$lastKey])) {
$branch[$lastKey] = $value;
}
}
}
$result = [
'lang' => [
'goods' => [
'ru' => $array1['ru']['lang']['goods'],
'en' => $array2['en']['lang']['goods'],
],
'main' => [
'title' => [
'ru' => $array1['ru']['lang']['main']['title'],
'en' => $array2['en']['lang']['main']['title'],
],
'description' => [
'ru' => $array1['ru']['lang']['main']['description'],
'en' => $array2['en']['lang']['main']['description']
]
]
];
$result = [
'lang' => [
'goods' => [
'ru' => $array1['ru']['lang']['goods'],
'en' => $array2['en']['lang']['goods']
],
'main' => [
'title' => [
'ru' => $array1['ru']['lang']['main']['title'],
'en' => $array2['en']['lang']['main']['title']
],
'description' => [
'ru' => $array1['ru']['lang']['main']['description'],
'en' => $array2['en']['lang']['main']['description']
]
]
]
];
function walk($data, $key, &$result) {
foreach ($data as $k => $v) {
if (!array_key_exists($k, $result)) {
$result[$k] = [];
}
if (!is_array($v) || array_keys($v) === range(0, count($v) - 1)) {
$result[$k][$key] = $v;
} else {
walk($v, $key, $result[$k]);
}
}
}
function merge(...$arrays) {
$result = [];
foreach ($arrays as $arr) {
$key = array_keys($arr)[0];
walk($arr[$key], $key, $result);
}
return $result;
}
$result = merge($array1, $array2);
$result = ['lang' => []];
foreach ([$array1, $array2] AS $ar) {
foreach ($ar AS $lang => $data) {
foreach ($data['lang'] AS $k => $v) {
switch ($k) {
case 'goods':
$result['lang'][$k][$lang] = $v;
break;
default:
foreach ($v AS $key => $description) {
$result['lang'][$k][$key][$lang] = $description;
}
}
}
}
}
SELECT DISTINCT
email,
phone
FROM
table
SELECT * FROM table1 t1, (
SELECT DISTINCT
email,
phone
FROM
table) AS t2
WHERE t1.email = t2.email AND t1.phone = t2.phone
let result = new Date(data.date).getHouts() + ":" + new Date(data.date).getMinutes();
$keys = array_keys($test);
var_export($keys);
И даже не спрашивайте зачем.Ну тогда не обижайся, если получится что я не угадал, и тебе не подходит array_keys(). Другие способы есть, но я не собираюсь сюда копировать весь мануал.