3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = [ 'abc' => [ [ 'foo' => '*', 'action' => 'Read', 'resource' => [ 'name' => 'name_1', 'patternType' => 'fixed', 'type' => 'partition', ], ], [ 'foo' => '*', 'action' => 'Write', 'resource' => [ 'name' => 'name_1', 'patternType' => 'fixed', 'type' => 'partition', ], ], [ 'foo' => '*', 'action' => 'Read', 'resource' => [ 'name' => 'name_2', 'patternType' => 'fixed', 'type' => 'partition', ], ], [ 'foo' => '*', 'action' => 'Alter', 'resource' => [ 'name' => 'name_2', 'patternType' => 'fixed', 'type' => 'partition', ], ], ], ]; foreach ($array as $key => &$sets) { foreach ($sets as $i => &$set) { $id = $set['resource']['name']; if (!isset($ref[$id])) { $set['action'] = (array) $set['action']; $ref[$id] = &$set['action']; } else { $ref[$id][] = $set['action']; unset($array[$key][$i]); } } } var_export($array);
Output for git.master, git.master_jit, rfc.property-hooks
array ( 'abc' => array ( 0 => array ( 'foo' => '*', 'action' => array ( 0 => 'Read', 1 => 'Write', ), 'resource' => array ( 'name' => 'name_1', 'patternType' => 'fixed', 'type' => 'partition', ), ), 2 => array ( 'foo' => '*', 'action' => array ( 0 => 'Read', 1 => 'Alter', ), 'resource' => array ( 'name' => 'name_2', 'patternType' => 'fixed', 'type' => 'partition', ), ), ), )

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