advent_of_code_2021/day_1/part_1.php

15 lines
259 B
PHP

<?php
$numbers = array_map('intval', explode("\n", file_get_contents('input.txt')));
$current = array_shift($numbers);
$count = 0;
foreach ($numbers as $number) {
if ($number > $current) {
$count++;
}
$current = $number;
}
echo $count;