function addParent($array, $parent = null) {
$result = [];
foreach ($array as $key => $value) {
if (isset($value['category'])) {
$result = \array_merge($result, addParent($value['category'], $value['@attributes']['code']));
} else {
if ($parent) {
$result[] = \array_merge($value['@attributes'], ['code_parent' => $parent]);
} else {
$result[] = $value['@attributes'];
}
}
}
return $result;
}
function addParent($array, $parent = null) {
$result = [];
foreach ($array as $key => $value) {
if (\is_null($parent)) {
$result[] = $value['@attributes'];
$result = \array_merge($result, addParent($value['category'], $value['@attributes']['code']));
} else {
$result[] = \array_merge($value['@attributes'], ['code_parent' => $parent]);
}
}
return $result;
}
<?php
if(isset($_POST['submit']))
$file = "logfilePhone.txt";
$text = date('Y-m-d H:i:s') . ' ';
$text .= $_POST['phone'];
$text .= "\r\n"; //перевод строки
file_put_contents($file,$text,FILE_APPEND);
?>
$files = glob("blocks/*.pdf");
$result = [];
foreach ($files as $filename) {
$time = filectime($filename);
if (isset($result[$time])) {
if (!is_array($result[$time])) {
$result[$time] = [$result[$time]];
}
}
$result[$time][] = $filename;
}
ksort($result);
foreach ($result as $time => $file) {
if (is_array($file)) {
foreach($file as $inner) {
include($inner);
}
} else {
include($file);
}
}