3v4l.org

run code in 300+ PHP versions simultaneously
<?php function facdef($n) { switch($n) { case 0: return 1; case 1: return 1; case 2: return 2; case 3: return 6; case 4: return 24; case 5: return 120; case 6: return 720; case 7: return 5040; case 8: return 40320; case 9: return 362880; case 10: return 3628800; case 11: return 39916800; case 12: return 479001600; case 13: return 6227020800; case 14: return 87178291200; case 15: return 1307674368000; case 16: return 20922789888000; case 17: return 355687428096000; case 18: return 6402373705728000; case 19: return 121645100408832000; case 20: return 2432902008176640000; case 21: return 51090942171709440000; case 22: return 1124000727777607680000; case 23: return 25852016738884976640000; } } function constify($a) { #regression constants return $a*0.424+0.548; } function scorefix($avg) { #if predicted score is small or negative, return something reasonable if ( $avg < 0.01 ) { return pow(10,(pow(10,$avg-1))) / 105.50984676065602; } else { return $avg; } } function sim($homeoff,$homedef,$awayoff,$awaydef,$mul,$natavg) { #returns homemu,awaymu for poisson to deal with return array(scorefix((($homeoff-$natavg)*max(constify($awaydef*$mul),0.25)/constify($natavg*$mul)+$awaydef)*$mul),scorefix((($homedef-$natavg)*max(constify($awayoff/$mul),0.25)/constify($natavg/$mul)+$awayoff)/$mul)); } function poisson($mu,$shift) { #returns array of poisson probabilities for scores $x = []; for ($i = 1 ; $i <= $shift ; $i++ ) { array_push($x,0.0); } $pcdf = 0.0; $a = exp(-1*$mu); echo count($a); while ( $pcdf < 0.999999 || count($x) < 5 ) { echo pow($mu,(count($x)-$shift))."\n"; echo facdef(count($x)-$shift)."\n"; array_push($x,$a*(pow($mu,(count($x)-$shift)))/facdef(count($x)-$shift)); echo count($x); $pcdf+=end($x); } return $x; } var_dump(poisson(1.1,0)); ?>
Output for git.master, git.master_jit, rfc.property-hooks
Fatal error: Uncaught TypeError: count(): Argument #1 ($value) must be of type Countable|array, float given in /in/k7dXn:75 Stack trace: #0 /in/k7dXn(86): poisson(1.1, 0) #1 {main} thrown in /in/k7dXn on line 75
Process exited with code 255.

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
90.4 ms | 401 KiB | 8 Q