3v4l.org

run code in 500+ PHP versions simultaneously
<?php $arr = [ 'id' => 5, 'name' => 'Item 5', 'all_parents' => [ 'id' => 4, 'name' => 'Item 4', 'all_parents' => [ 'id' => 3, 'name' => 'Item 3', 'all_parents' => [ 'id' => 2, 'name' => 'Item 2', 'all_parents' => [ 'id' => 1, 'name' => 'Item 1', 'all_parents' => null ] ] ] ] ]; class Recursing { public function generateBreadcrumb($structure): array { return array_merge( empty($structure['all_parents']) ? [] : $this->generateBreadcrumb($structure['all_parents']), [['id' => $structure['id'], 'name' => $structure['name']]] ); } } $test = new Recursing; var_export($test->generateBreadcrumb($arr));
Output for rfc.property-hooks, git.master, git.master_jit
array ( 0 => array ( 'id' => 1, 'name' => 'Item 1', ), 1 => array ( 'id' => 2, 'name' => 'Item 2', ), 2 => array ( 'id' => 3, 'name' => 'Item 3', ), 3 => array ( 'id' => 4, 'name' => 'Item 4', ), 4 => array ( 'id' => 5, 'name' => 'Item 5', ), )

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:
48.93 ms | 1295 KiB | 4 Q