Source Code:
(back to article)
<?php $numbers = [5, 10, 15, 20, 25]; $prev = null; foreach ($numbers as $number) { if ($prev !== null) { $diff = $number - $prev; echo "The difference between $number and its previous value is $diff\n"; } $prev = $number; }
Result:
Report an issue