function view(int ...$numbers) {
$string = "";
foreach ($numbers as $index => $number) {
if ($index === 0) {
$string = $number;
} elseif (($index % 2 === 0 && $index !== 0)) {
if (($index + 1) === count($numbers)) {
$string .= "\n- " . $number . " -";
} else {
$string .= "\n" . $number;
}
} else {
$string .= " - " . $number;
}
}
echo $string;
}
1 - 2
3 - 4
5 - 6
- 7 -
1 - 2
3 - 4
5 - 6