3v4l.org

run code in 300+ PHP versions simultaneously
<?php // Capture the list of taste observations across analyses and phases of analysis $taste_observations = array(); // Temporary test data for Stack Overflow Question $taste_observations[] = [ 'analyst' => 'Ken', 'phase' => 'Entrance', 'taste' => 'Sweet', 'intensity' => 1 ]; $taste_observations[] = [ 'analyst' => 'Ken', 'phase' => 'Entrance', 'taste' => 'Spicy', 'intensity' => 1 ]; $taste_observations[] = [ 'analyst' => 'Ken', 'phase' => 'Center', 'taste' => 'Sweet', 'intensity' => 2 ]; $taste_observations[] = [ 'analyst' => 'Bob', 'phase' => 'Entrance', 'taste' => 'Savory', 'intensity' => 1 ]; $taste_observations[] = [ 'analyst' => 'Bob', 'phase' => 'After', 'taste' => 'Sweet', 'intensity' => 2, ]; $taste_summary = []; foreach($taste_observations as $taste_observation) { $taste_summary[$taste_observation['taste']] = [ 'taste' => $taste_observation['taste'], 'count' => 1 + ($taste_summary[$taste_observation['taste']]['count'] ?? 0), 'max' => max($taste_summary[$taste_observation['taste']]['max'] ?? 0, $taste_observation['intensity']), 'sum' => $taste_observation['intensity'] + ($taste_summary[$taste_observation['taste']]['sum'] ?? 0) ]; } ksort($taste_summary); $taste_summary = array_values($taste_summary); print_r($taste_summary);
Output for git.master, git.master_jit, rfc.property-hooks
Array ( [0] => Array ( [taste] => Savory [count] => 1 [max] => 1 [sum] => 1 ) [1] => Array ( [taste] => Spicy [count] => 1 [max] => 1 [sum] => 1 ) [2] => Array ( [taste] => Sweet [count] => 3 [max] => 2 [sum] => 5 ) )

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:
101.6 ms | 406 KiB | 5 Q