3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = [ [ "points" => 10, "details" => ["name" => "Team A", "rank" => ""] ], [ "points" => 10, "details" => ["name" => "Team B", "rank" => ""] ], [ "points" => 8, "details" => ["name" => "Team C", "rank" => ""] ], [ "points" => 6, "details" => ["name" => "Team D", "rank" => ""] ], ]; $denseRank = 0; foreach ($array as ['points'=> $points, 'details' => ['rank' => &$rank]]) { $denseRanks[$points] ??= ++$denseRank; $rank = $denseRanks[$points]; } var_export($array);
Output for git.master, git.master_jit, rfc.property-hooks
array ( 0 => array ( 'points' => 10, 'details' => array ( 'name' => 'Team A', 'rank' => 1, ), ), 1 => array ( 'points' => 10, 'details' => array ( 'name' => 'Team B', 'rank' => 1, ), ), 2 => array ( 'points' => 8, 'details' => array ( 'name' => 'Team C', 'rank' => 2, ), ), 3 => array ( 'points' => 6, 'details' => array ( 'name' => 'Team D', 'rank' => 3, ), ), )

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