3v4l.org

run code in 300+ PHP versions simultaneously
<?php $categories = array( 'category_1' => array( 'name' => 'Category 1', 'column' => '1' ), 'category_2' => array( 'name' => 'Category 2', 'column' => '2' ), 'category_3' => array( 'name' => 'Category 2', 'column' => '1' ), 'category_4' => array( 'name' => 'Category 4', 'column' => '3' ), 'category_4' => array( 'name' => 'Category 4', 'column' => '2' ), ); $output = array(); foreach($categories as $catName => $category) { $columnNum = $category['column']; $key = 'column_' . $columnNum; if (!isset($output[$key] )) { $output[$key] = array($catName); } else { $output[$key][] = $catName; } } var_dump($output);
Output for git.master, git.master_jit, rfc.property-hooks
array(2) { ["column_1"]=> array(2) { [0]=> string(10) "category_1" [1]=> string(10) "category_3" } ["column_2"]=> array(2) { [0]=> string(10) "category_2" [1]=> string(10) "category_4" } }

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:
36.74 ms | 402 KiB | 8 Q