3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr = [ 0 => [ "id" => "1", "parent_cat_name" => "0", "cat_name" => "Test 1", "status" => "1", "position" => "1", "created_at" => "2019-09-03 09:27:45", "updated_at" => "2019-09-03 11:00:54", "children" => [ 0 => [ "id" => "2", "parent_cat_name" => "1", "cat_name" => "Test 2", "status" => "1", "position" => "2", "created_at" => "2019-09-03 09:28:19", "updated_at" => "2019-09-03 11:01:00", "children" => [ 0 => [ "id" => "4", "parent_cat_name" => "2", "cat_name" => "Test 4", "status" => "1", "position" => "4", "created_at" => "2019-09-03 09:35:20", "updated_at" => "2019-09-03 11:01:03", "children" => [ 0 => [ "id" => "5", "parent_cat_name" => "4", "cat_name" => "Test 5", "status" => "1", "position" => "3", "created_at" => "2019-09-07 05:55:09", "updated_at" => "2019-09-07 05:55:09", ], ], ], ], ], ], ], 1 => [ "id" => "3", "parent_cat_name" => "0", "cat_name" => "Test 3", "status" => "1", "position" => "4", "created_at" => "2019-09-03 09:35:10", "updated_at" => "2019-09-03 11:00:58", ], ]; /** * @param $data */ /** * @param $data */ function custom_function($data) { $result = []; if (is_array($data) && count($data) > 0) { $result[] = '<ul>'; foreach ($data as $entry) { if (isset($entry['children'])) { $result[] = sprintf('<li>%s %s</li>', $entry['cat_name'], custom_function($entry['children'])); } else { $result[] = sprintf('<li>%s</li>', $entry['cat_name']); } } $result[] = '</ul>'; } return implode($result); } echo custom_function($arr);
Output for git.master, git.master_jit, rfc.property-hooks
<ul><li>Test 1 <ul><li>Test 2 <ul><li>Test 4 <ul><li>Test 5</li></ul></li></ul></li></ul></li><li>Test 3</li></ul>

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