$value) { if ($value != $old_item[$key]) { // These values aren't the same // Print diff print_diff($key, $old_item[$key], COLOR_RED); print_diff($key, $value, COLOR_GREEN); } else { // Values are the same, print as is print_diff($key, $value, null); } } print(" }\n"); } } // The remaining items in the old list are removed foreach ($old_list as $item) { if ($item['removal'] == 'Unsafe') { // Exclude Unsafe items continue; } // List this item as removed item. print("\e[31m-{\e[0m\n"); foreach ($item as $key => $value) { print_diff($key, $value, null); } print("\e[31m-}\e[0m\n"); } exit(0); function print_diff(string $key, string|array|null $value, ?int $color): void { if ($color == COLOR_RED) { $symbol = '-'; $color_begin = "\e[31m"; $color_end = "\e[0m"; } else if ($color == COLOR_GREEN) { $symbol = '+'; $color_begin = "\e[32m"; $color_end = "\e[0m"; } else { $symbol = ' '; $color_begin = ''; $color_end = ''; } if ($value == null) { printf("$symbol$color_begin $key: null,$color_end"); } else if (is_string($value)) { printf("$symbol$color_begin $key: $value,$color_end"); } else if (is_array($value)) { printf("$symbol$color_begin $key: [$color_end"); foreach ($value as $item) { printf("$symbol$color_begin $item,$color_end"); } printf("$symbol$color_begin ],$color_end"); } } function find_in_old_list(string $id): ?array { global $old_list; $c = count($old_list); for ($i = 0; $i < $c; ++$i) { $item = $old_list[$i]; if ($item['id'] == $id) { array_splice($old_list, $i, 1); return $item; } } return null; } function get_removal(string $uad_removal): string { switch ($uad_removal) { default: case "Recommended": return "delete"; case "Advanced": return "replace"; case "Expert": return "caution"; case "Unsafe": return "unsafe"; } }