3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $arr_input = array(); $arr_input[1] = array("parent"=>"null", "name"=>"one"); $arr_input[2] = array("parent"=>"1", "name"=>"two"); $arr_input[3] = array("parent"=>"null", "name"=>"three"); $arr_input[4] = array("parent"=>"3", "name"=>"four"); $arr_input[5] = array("parent"=>"4", "name"=>"five"); $arr_input[6] = array("parent"=>"2", "name"=>"six"); $arr_input[7] = array("parent"=>"3", "name"=>"seven"); $arr_input[8] = array("parent"=>"2", "name"=>"eight"); $input_id = 6; // variable input if(isset($arr_input[$input_id])) { echo $arr_input[$input_id]['name']; $parent_id = $arr_input[$input_id]['parent']; while($parent_id!='null') { if(isset($arr_input[$parent_id])) { echo "/".$arr_input[$parent_id]['name']; } $parent_id = $arr_input[$parent_id]['parent_id']; } }

Verbose script

This script was stopped because it was generating too much output