3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = array( 'Группа' => array( 'Ид' => 'aed92e32-a88d-11e9-b74b-002522d5a8f5', 'Наименование' => '01_ДЛЯ ПРОДАЖ', 'Группы' => array( 'Группа' => array( '10' => array( 'Ид' => '776ea23c-4a7a-11ea-a3ba-002522d5a8f5', 'Наименование' => 'Литература', 'Группы' => array( 'Группа' => array( 'Ид' => 'faa0a831-4b3a-11ea-a3ba-002522d5a8f5', 'Наименование' => 'Журналы учета', ), ), ), ) )) ); function list_items($array, $parent = 0) { $output = array(); if (isset($array['Ид'])) { $array = array($array); } foreach ($array as $arr) { if (!is_array($arr)) echo $arr; $output[] = array('id' => $arr['Ид'], 'name' => $arr['Наименование'], 'parent' => $parent); if (is_array($arr['Группы']['Группа'] ?? NULL)) { $output = array_merge($output, list_items($arr['Группы']['Группа'], $arr['Ид'])); } } return $output; } $items = list_items($array); print_r($items);
Output for git.master, git.master_jit, rfc.property-hooks
Array ( [0] => Array ( [id] => aed92e32-a88d-11e9-b74b-002522d5a8f5 [name] => 01_ДЛЯ ПРОДАЖ [parent] => 0 ) [1] => Array ( [id] => 776ea23c-4a7a-11ea-a3ba-002522d5a8f5 [name] => Литература [parent] => aed92e32-a88d-11e9-b74b-002522d5a8f5 ) [2] => Array ( [id] => faa0a831-4b3a-11ea-a3ba-002522d5a8f5 [name] => Журналы учета [parent] => 776ea23c-4a7a-11ea-a3ba-002522d5a8f5 ) )

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