fork download
  1. <?php
  2. $array = [0.0, 0.19, 0.5, 0.75, 1.0, 1.25, 1.5, 1.75, 2.0, 2.25];
  3.  
  4. $result = [];
  5. for ($i = 1; $i < count($array); $i++) {
  6. $result[] = abs($array[$i - 1] - $array[$i]);
  7. }
  8.  
  9. print_r($result);
  10. ?>
Success #stdin #stdout 0.01s 82880KB
stdin
Standard input is empty
stdout
Array
(
    [0] => 0.19
    [1] => 0.31
    [2] => 0.25
    [3] => 0.25
    [4] => 0.25
    [5] => 0.25
    [6] => 0.25
    [7] => 0.25
    [8] => 0.25
)