3v4l.org

run code in 300+ PHP versions simultaneously
<?php $topics_percentage = [ ['id' => 8989, 'cat' => 'Category 1', 'completed' => 0], ['id' => 8919, 'cat' => 'Category 2', 'completed' => 1], ['id' => 8913, 'cat' => 'Category 2', 'completed' => 1], ['id' => 8947, 'cat' => 'Category 1', 'completed' => 1], ['id' => 8949, 'cat' => 'Category 3', 'completed' => 1], ]; $result = []; $lookup = ['noncompleted', 'completed']; foreach ($topics_percentage as ['cat' => $cat, 'completed' => $comp]) { $result[$cat][$lookup[$comp]] = ($result[$cat][$lookup[$comp]] ?? 0) + 1; } var_export($result);
Output for git.master_jit, git.master, rfc.property-hooks
array ( 'Category 1' => array ( 'noncompleted' => 1, 'completed' => 1, ), 'Category 2' => array ( 'completed' => 2, ), 'Category 3' => array ( 'completed' => 1, ), )

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