3v4l.org

run code in 300+ PHP versions simultaneously
<?php /* 1 2 3 4 5 - 6 - 7 */ $a = ['d'=>1, 'l'=>&$b, 'r'=>&$c]; $b = ['d'=>2, 'l'=>&$d, 'r'=>&$e]; $c = ['d'=>3, 'l'=>null, 'r'=>&$f]; $d = ['d'=>4, 'l'=>null, 'r'=>&$g]; $e = ['d'=>5, 'l'=>null, 'r'=>null]; $f = ['d'=>6, 'l'=>null, 'r'=>null]; $g = ['d'=>7, 'l'=>null, 'r'=>null]; bfs($a); echo "\n"; dfs($a); function bfs($t) { $queue = [$t]; while ($queue) { $node = array_shift($queue); echo $node['d']; if (is_array($node['l'])) { array_push($queue, $node['l']); } if (is_array($node['r'])) { array_push($queue, $node['r']); } } } function dfs($t) { $stack = [$t]; while ($stack) { $node = array_pop($stack); echo $node['d']; if (is_array($node['r'])) { array_push($stack, $node['r']); } if (is_array($node['l'])) { array_push($stack, $node['l']); } } }
Output for git.master, git.master_jit, rfc.property-hooks
1234567 1247536

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:
32.44 ms | 401 KiB | 8 Q