Newbie here in PHP programming. I have some question regarding arrays. How can I get the difference between adjacent values in an array?
$value = array(2, 5, 9,
Just use a simple for loop:
for
$diffs = array(); for ($i = 1, $n = count($value); $i < $n; $i++) { $diffs[] = $value[$i] - $value[$i-1]; }