names[$nrow['sys_name']] = $nrow['name']; } // Несовпадения по именам. $this->names['lvl'] = $this->names['level']; $this->printAll(); $this->printUnknown(); } private function printer(array $data, string $title): string { $result = ''; foreach ($data as $k=>$v) { if ($k === array_key_first($data)) { $result .= "
$title: "; } $result .= $this->namer($k, $v); } return $result; } private function printAll(): void { foreach (Db::getRows('select name, info, date2, date3, id, tr from priems order by name') as $prow) { $d2 = Conversion::dataStringToArray($prow['date2']); $d3 = Conversion::dataStringToArray($prow['date3']); $tr = Conversion::dataStringToArray($prow['tr']); $d2s = $this->printer($d2, 'date2'); $d3s = $this->printer($d3, 'date3'); $trs = $this->printer($tr, 'Требуется'); $dallk = array_flip(array_keys(array_merge($d2, $d3, $tr))); $this->parameters = array_merge($dallk, $this->parameters); echo "
{$prow['name']} id:{$prow['id']}
{$prow['info']} $trs $d2s $d3s
"; } } private function namer($k, $v): string { return match (true) { $this->names[$k] => "
$this->names[$k] = $v", str_starts_with($k, 'add_') && $this->names[str_replace('add_', '', $k)] => "
{$this->names[str_replace('add_', '', $k)]} = $v", str_starts_with($k, 'tr_') && $this->names[str_replace('tr_', '', $k)] => "
{$this->names[str_replace('tr_', '', $k)]} = $v", default => "
$k = $v", }; } private function printUnknown(): void { $sorted = []; foreach ($this->parameters as $pa=>$va) { if ($this->names[str_replace('add_', '', $pa)] || $this->names[str_replace('tr_', '', $pa)]) { continue; } $sorted[] = $pa; } echo '
Неизвестные параметры:
'; foreach (array_chunk($sorted, 10) as $re) { echo implode(', ', $re) . '
'; } } } echo << @import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono&display=swap'); body {font-family: 'JetBrains Mono', monospace; font-size: small; background-color: lavender;} hr {border: 1px solid darkgreen;} i {color: dimgrey;} div {margin: 10px 0; padding: 4px; background-color: ghostwhite;} div > b:first-child {margin-left: 5px; color: darkslategrey;} div > b:first-child:before {content: '⭕ '} HTML; $np = new ShowPriems();