3v4l.org

run code in 300+ PHP versions simultaneously
<?php $yaml = [ 'components' => [ [ 'cachet' => [ 'componentgroup' => 'Bar', 'componentname' => 'Name1' ] ], [ 'cachet' => [ 'componentgroup' => 'Bar', 'componentname' => 'Name2' ] ] ] ]; $yamlMap = []; foreach ($yaml['components'] as $yamlComponent) { $key = $yamlComponent['cachet']['componentgroup']; $value = $yamlComponent['cachet']['componentname']; // Lets initialize the key to be an array so that we may collect multiple values if(!array_key_exists($key, $yamlMap)) { $yamlMap[$key] = []; } // lets add the value to the map under the key $yamlMap[$key][] = $value; } var_dump($yamlMap);
Output for git.master_jit, git.master, rfc.property-hooks
array(1) { ["Bar"]=> array(2) { [0]=> string(5) "Name1" [1]=> string(5) "Name2" } }

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