3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $array = array(9,4,-3,-10); function stddev($array){ //Don Knuth is the $deity of algorithms //http://en.wikipedia.org/wiki/Algorithms_for_calculating_variance#III._On-line_algorithm $n = 0; $mean = 0; $M2 = 0; foreach($array as $x){ $n++; $delta = $x - $mean; $mean = $mean + $delta/$n; $M2 = $M2 + $delta*($x - $mean); } $variance = $M2/($n - 1); return sqrt($variance); } stddev($array); ?>
Output for 4.3.0 - 5.6.28, hhvm-3.12.0, 7.0.0 - 7.1.0
Output for hhvm-3.10.0

Process exited with code 153.