3v4l.org

run code in 300+ PHP versions simultaneously
<?php function appendToValues(&$array, $value) { foreach ($array as &$item) { if ($item['attribute_code'] === 'harddisk') { $item['attribute_value'][] = $value; } elseif(is_array($item['attribute_value'])) { appendToValues($item['attribute_value'], $value); } } } $array = [ 3 => [ 'attribute_code' => 'category', 'attribute_value' => [ 4 => [ 'attribute_code' => 'hardware', 'attribute_value' => [ 5 => [ 'attribute_code' => 'harddisk', 'attribute_value' => [ 6 => [ 'attribute_code' => 'small', 'attribute_value' => '132gb', ], ], ], ], ], ], ], ]; var_dump($array); appendToValues($array, ['attribute_code' => 'medium', 'attribute_value' => '256gb']); var_dump($array);
Output for git.master, git.master_jit, rfc.property-hooks
array(1) { [3]=> array(2) { ["attribute_code"]=> string(8) "category" ["attribute_value"]=> array(1) { [4]=> array(2) { ["attribute_code"]=> string(8) "hardware" ["attribute_value"]=> array(1) { [5]=> array(2) { ["attribute_code"]=> string(8) "harddisk" ["attribute_value"]=> array(1) { [6]=> array(2) { ["attribute_code"]=> string(5) "small" ["attribute_value"]=> string(5) "132gb" } } } } } } } } array(1) { [3]=> array(2) { ["attribute_code"]=> string(8) "category" ["attribute_value"]=> array(1) { [4]=> array(2) { ["attribute_code"]=> string(8) "hardware" ["attribute_value"]=> array(1) { [5]=> array(2) { ["attribute_code"]=> string(8) "harddisk" ["attribute_value"]=> array(2) { [6]=> array(2) { ["attribute_code"]=> string(5) "small" ["attribute_value"]=> string(5) "132gb" } [7]=> array(2) { ["attribute_code"]=> string(6) "medium" ["attribute_value"]=> string(5) "256gb" } } } } } } } }

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:
153.75 ms | 411 KiB | 5 Q