$adsNew = array_column($ads, 'idDeal', 'id');
$adsNew = array_flip($adsNew);
// Координаты
wrAr(['Coordinates'],[['Lat', $aRes['PROPERTY_LATITUDE_VALUE']],['Lng', $aRes['PROPERTY_LONGITUDE_VALUE']]]);
<Coordinates>
<Lat>55.2212</Lat>
<Lng>61.3318</Lng>
</Coordinates>
function wrAr ($start = false, $value){
global $xml;
$data = [];
$rv = array_filter($val, 'is_array');
if (count($rv)==0) {
$value[] = $value;
}
$n = 0;
foreach($value as $field) {
if(empty($field['1'])) {
continue;
} else {
$n++;
$val [] = $field;
}
}
if ($n == 0) {
return NULL;
}
if (!empty($start)) {
foreach($start as $st) {
$data[] = $xml->startElement($st);
}
}
foreach($val as $value) {
if (empty($value)) {
continue;
}
$data[] = $xml->writeElement($value['0'], !$value['2'] ? $value['1'] : $value['2'][$value['1']]);
}
$start = array_reverse($start);
foreach($start as $st) {
$data[] = $xml->endElement();
}
return $data;
}