3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = [ ['mail' => 'mail1@example.com', 'coins' => '25000.00'], ['mail' => 'mail2@example.com', 'coins' => '500000.00'], ['mail' => 'mail1@example.com', 'coins' => '10000.00'], ['mail' => 'mail2@example.com', 'coins' => '10000.00'], ['mail' => 'mail3@example.com', 'coins' => '20000.00'], ]; $result = []; foreach ($array as ['mail' => $mail, 'coins' => $coins]) { if (!isset($result[$mail])) { $result[$mail] = [1, $coins]; // declare the data for the first instance of mail } else { ++$result[$mail][0]; // increment the running count $result[$mail][1] += $coins; // add coins to running total } } foreach ($result as $mail => $row) { printf("%s (%d), %.2f coins\n", $mail, ...$row); }
Output for git.master, git.master_jit, rfc.property-hooks
mail1@example.com (2), 35000.00 coins mail2@example.com (2), 510000.00 coins mail3@example.com (1), 20000.00 coins

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:
14.99 ms | 405 KiB | 5 Q