Open stackpr opened 4 years ago
Once the count macro is run on both old and new, they can be merged:
<?php $files = array( 'active.txt' => array(), 'backup.txt' => array(), ); $all = array(); foreach ($files as $path => &$data) { foreach (file($path) as $line) { list($folder, $count) = explode("\t", $line, 2); $data[$folder] = $count; $all[] = $folder; } } unset($data); $all = array_unique($all); sort($all); echo "Folder\tActive\tBackup\n"; foreach ($all as $folder) { $line = $folder; foreach ($files as $data) { if (isset($data[$folder])) { $line .= "\t" . intval($data[$folder]); } else { $line .= "\t-"; } } echo $line . "\n"; }
Once the count macro is run on both old and new, they can be merged: