3v4l.org

run code in 300+ PHP versions simultaneously
<?php $tires = [ 'Desert'=>array('dry'=>10, 'wet'=>4, 'snow'=>1), 'Ocean'=>array('dry'=>6, 'wet'=>8, 'snow'=>6), 'RainForest'=>array('dry'=>6, 'wet'=>10, 'snow'=>6), 'Glacier'=>array('dry'=>4, 'wet'=>9, 'snow'=>10), 'Prairie'=>array('dry'=>7, 'wet'=>7, 'snow'=>7), ]; $minimumScore = 5; // remove tires that have a single rating less than minimum $filtered = array_filter($tires, function (array $data) use ($minimumScore) { return min($data) >= $minimumScore; }); // calculate scores as average of score per category $scores = array_map(function (array $data) { return array_sum($data) / count($data); }, $filtered); // find maximum of scores $bestScore = max($scores); // find keys with the best score $bestTires = array_keys($scores, $bestScore); // there could be more than one tire with same score, pick the first $bestTire = array_shift($bestTires); echo sprintf( '%s is the best tire with the score: %s', $bestTire, $bestScore );
Output for git.master, git.master_jit, rfc.property-hooks
RainForest is the best tire with the score: 7.3333333333333

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:
61.91 ms | 1642 KiB | 4 Q