3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = [ [ 'key_1' => 'FOO', 'key_2' => 'FTU-1', 'cats' => '/30/' ], [ 'key_1' => 'FOO', 'key_2' => 'FTU-2', 'cats' => '/30/' ], [ 'key_1' => 'FOO', 'key_2' => 'FTU-3', 'cats' => '/30/10/' ], [ 'key_1' => 'FOO', 'key_2' => 'FTU-4', 'cats' => '/15/' ], [ 'key_1' => 'FOO', 'key_2' => 'FTU-5', 'cats' => '/10/' ], [ 'key_1' => 'FOO', 'key_2' => 'FTU-6', 'cats' => '/15/' ], ]; $result = []; foreach ($array as $row) { $cats = preg_split('#/#', $row['cats'], 0, PREG_SPLIT_NO_EMPTY); foreach ($cats as $cat) { $result[$cat][] = $row; } } var_export($result);
Output for git.master_jit, git.master
array ( 30 => array ( 0 => array ( 'key_1' => 'FOO', 'key_2' => 'FTU-1', 'cats' => '/30/', ), 1 => array ( 'key_1' => 'FOO', 'key_2' => 'FTU-2', 'cats' => '/30/', ), 2 => array ( 'key_1' => 'FOO', 'key_2' => 'FTU-3', 'cats' => '/30/10/', ), ), 10 => array ( 0 => array ( 'key_1' => 'FOO', 'key_2' => 'FTU-3', 'cats' => '/30/10/', ), 1 => array ( 'key_1' => 'FOO', 'key_2' => 'FTU-5', 'cats' => '/10/', ), ), 15 => array ( 0 => array ( 'key_1' => 'FOO', 'key_2' => 'FTU-4', 'cats' => '/15/', ), 1 => array ( 'key_1' => 'FOO', 'key_2' => 'FTU-6', 'cats' => '/15/', ), ), )

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