3v4l.org

run code in 300+ 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 git.master, git.master_jit, rfc.property-hooks
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:
117.74 ms | 406 KiB | 5 Q