fork download
  1. <?php
  2.  
  3. $close = array(100,101,99,98,99,103,102);
  4. $new = array();
  5.  
  6. for ($i=1; $i <count($close) ; $i++) {
  7.  
  8. $val = round($close[$i] / $close[$i-1], 2);
  9.  
  10. array_push($new, $val);
  11.  
  12. }
  13.  
  14. var_dump($new);
  15.  
  16.  
Success #stdin #stdout 0.01s 20568KB
stdin
Standard input is empty
stdout
array(6) {
  [0]=>
  float(1.01)
  [1]=>
  float(0.98)
  [2]=>
  float(0.99)
  [3]=>
  float(1.01)
  [4]=>
  float(1.04)
  [5]=>
  float(0.99)
}