3v4l.org

run code in 300+ PHP versions simultaneously
<?php $testArray = [[ "lineupSet" => [ [[ "formula" => [ "totalPoints" => 214.61, ], "name" => "test1", ], [ "formula" => [ "totalPoints" => 201.17, ], "name" => "test2", ]], [ "formula" => [ "totalPoints" => 5.01, ], "name" => "test3", ]], ], [ "lineupSet" => [ [[ "formula" => [ "totalPoints" => 220.66, ], "name" => "test1", ], [ "formula" => [ "totalPoints" => 214.76, ], "name" => "test2", ]], ], ], [ "lineupSet" => [ [[ "formula" => [ "totalPoints" => 205.71, ], "name" => "test1", ], [ "formula" => [ "totalPoints" => 204.43, ], "name" => "test2", ]], ], ], [ "lineupSet" => [ [[ "formula" => [ "totalPoints" => 205.48, ], "name" => "test1", ], [ "formula" => [ "totalPoints" => 203.51, ], "name" => "test2", ]], ], ]]; function sum_points($v) { $totalPoints = 0; foreach ($v['lineupSet'] as $lset) { if (isset($lset['formula'])) { $totalPoints += $lset['formula']['totalPoints']; } else { foreach ($lset as $l) { $totalPoints += $l['formula']['totalPoints']; } } } return $totalPoints; } function sort_points($a, $b) { return sum_points($b) - sum_points($a); } usort($testArray, 'sort_points'); print_r($testArray[0]);
Output for git.master, git.master_jit, rfc.property-hooks
Array ( [lineupSet] => Array ( [0] => Array ( [0] => Array ( [formula] => Array ( [totalPoints] => 220.66 ) [name] => test1 ) [1] => Array ( [formula] => Array ( [totalPoints] => 214.76 ) [name] => test2 ) ) ) )

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:
103.44 ms | 407 KiB | 5 Q