3v4l.org

run code in 300+ PHP versions simultaneously
<?php function entropy($a, $b) { $options = array_filter(func_get_args()); $total = array_sum($options); $entropy = 0; foreach ($options as $size) { $part = $size / $total; $entropy -= $part * log($part, 2); } return $entropy; } var_dump('1 4', entropy(1, 4)); // abbbb echo "\n"; var_dump('2 2', entropy(2, 2)); // aabb echo "\n"; var_dump('2 2 2', entropy(2, 2, 2)); // aabbcc echo "\n"; var_dump('2 2 2 2', entropy(2, 2, 2, 2)); // aabbccdd echo "\n";
Output for git.master, git.master_jit, rfc.property-hooks
string(3) "1 4" float(0.7219280948873623) string(3) "2 2" float(1) string(5) "2 2 2" float(1.584962500721156) string(7) "2 2 2 2" float(2)

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:
43.48 ms | 401 KiB | 8 Q