3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Sqltree { private $FlatTable, $paths; public function __construct($FlatTable) { $this->FlatTable = $FlatTable; } public function generateTable($tree) { $this->paths = array(); $this->path_recursion($tree, array()); print_r($paths); } private function path_recursion($tree, $parents) { //Path erzeugen $this->paths[] = array($tree, $tree, 0); foreach($parents as $parent) { $this->paths[] = array($parent['id'], $tree['id'], $parents['path_length']); $parents['path_length']++; } if(is_array($tree['children'])) { $parents = array('id' => $tree['id'], 'path_length' => 1); foreach($tree['children'] as $child) { $this->path_recursion($child, $parents); } } } public static function CreateTable($FlatTable) { $sql = "CREATE TABLE ClosureTable ( ancestor_id INT NOT NULL REFERENCES $FlatTable(id), descendant_id INT NOT NULL REFERENCES $FlatTable(id), path_length INT, PRIMARY KEY (ancestor_id, descendant_id) );"; sql::create($sql); } } $tree = array('id' => 1, 'children' => array(array('id' => 2, 'children' => array('id' => 4, 'children' => false)), array('id' => 3, 'children' => false))); print_r($tree); $sqltree = new SqlTree('asd'); $sqltree->generateTable($tree); ?>
Output for git.master, git.master_jit
Array ( [id] => 1 [children] => Array ( [0] => Array ( [id] => 2 [children] => Array ( [id] => 4 [children] => ) ) [1] => Array ( [id] => 3 [children] => ) ) ) Warning: Trying to access array offset on value of type int in /in/FcpdH on line 16 Warning: Trying to access array offset on value of type int in /in/FcpdH on line 16 Warning: Trying to access array offset on value of type int in /in/FcpdH on line 16 Warning: Trying to access array offset on value of type int in /in/FcpdH on line 16 Warning: Trying to access array offset on value of type int in /in/FcpdH on line 16 Warning: Trying to access array offset on value of type int in /in/FcpdH on line 16 Warning: Trying to access array offset on value of type int in /in/FcpdH on line 19 Warning: Trying to access array offset on value of type int in /in/FcpdH on line 16 Warning: Trying to access array offset on value of type bool in /in/FcpdH on line 16 Warning: Trying to access array offset on value of type int in /in/FcpdH on line 16 Warning: Trying to access array offset on value of type bool in /in/FcpdH on line 16 Warning: Trying to access array offset on value of type bool in /in/FcpdH on line 19 Warning: Trying to access array offset on value of type int in /in/FcpdH on line 16 Warning: Trying to access array offset on value of type int in /in/FcpdH on line 16 Warning: Undefined variable $paths in /in/FcpdH on line 10
Output for rfc.property-hooks
Array ( [id] => 1 [children] => Array ( [0] => Array ( [id] => 2 [children] => Array ( [id] => 4 [children] => ) ) [1] => Array ( [id] => 3 [children] => ) ) ) Warning: Trying to access array offset on int in /in/FcpdH on line 16 Warning: Trying to access array offset on int in /in/FcpdH on line 16 Warning: Trying to access array offset on int in /in/FcpdH on line 16 Warning: Trying to access array offset on int in /in/FcpdH on line 16 Warning: Trying to access array offset on int in /in/FcpdH on line 16 Warning: Trying to access array offset on int in /in/FcpdH on line 16 Warning: Trying to access array offset on int in /in/FcpdH on line 19 Warning: Trying to access array offset on int in /in/FcpdH on line 16 Warning: Trying to access array offset on false in /in/FcpdH on line 16 Warning: Trying to access array offset on int in /in/FcpdH on line 16 Warning: Trying to access array offset on false in /in/FcpdH on line 16 Warning: Trying to access array offset on false in /in/FcpdH on line 19 Warning: Trying to access array offset on int in /in/FcpdH on line 16 Warning: Trying to access array offset on int in /in/FcpdH on line 16 Warning: Undefined variable $paths in /in/FcpdH on line 10

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:
40.47 ms | 404 KiB | 8 Q