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']); } } }

Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).

VersionSystem time (s)User time (s)Memory (MiB)
8.3.60.0000.01518.55
8.3.50.0160.00416.47
8.3.40.0110.00418.81
8.3.30.0100.00718.71
8.3.20.0040.00419.14
8.3.10.0000.00721.86
8.3.00.0080.00019.48
8.2.180.0180.00316.63
8.2.170.0000.01522.96
8.2.160.0150.00020.29
8.2.150.0040.00425.66
8.2.140.0080.00024.66
8.2.130.0070.00020.38
8.2.120.0040.00426.35
8.2.110.0040.00421.07
8.2.100.0070.00418.03
8.2.90.0000.00719.21
8.2.80.0030.00518.00
8.2.70.0000.00817.63
8.2.60.0030.00617.68
8.2.50.0040.00418.12
8.2.40.0040.00422.10
8.2.30.0040.00419.25
8.2.20.0040.00418.12
8.2.10.0000.00718.01
8.2.00.0020.00518.13
8.1.280.0100.01025.92
8.1.270.0050.00223.84
8.1.260.0040.00426.35
8.1.250.0070.00028.09
8.1.240.0060.00319.20
8.1.230.0040.00817.42
8.1.220.0060.00317.91
8.1.210.0090.00018.77
8.1.200.0030.00717.23
8.1.190.0040.00417.23
8.1.180.0040.00418.10
8.1.170.0050.00318.47
8.1.160.0000.00818.91
8.1.150.0000.00720.58
8.1.140.0000.00719.47
8.1.130.0070.00018.95
8.1.120.0000.00717.47
8.1.110.0030.00517.35
8.1.100.0040.00417.49
8.1.90.0040.00417.37
8.1.80.0060.00317.48
8.1.70.0040.00417.48
8.1.60.0000.00717.57
8.1.50.0020.00517.54
8.1.40.0060.00317.55
8.1.30.0030.00517.59
8.1.20.0000.00817.61
8.1.10.0070.00017.60
8.1.00.0030.00517.57
8.0.300.0000.00818.77
8.0.290.0000.00716.75
8.0.280.0030.00318.34
8.0.270.0030.00417.16
8.0.260.0030.00316.72
8.0.250.0000.00716.99
8.0.240.0000.00916.89
8.0.230.0070.00017.00
8.0.220.0070.00016.80
8.0.210.0030.00316.90
8.0.200.0070.00016.85
8.0.190.0030.00617.01
8.0.180.0040.00416.95
8.0.170.0040.00416.92
8.0.160.0030.00316.93
8.0.150.0030.00516.86
8.0.140.0000.00716.88
8.0.130.0000.00813.35
8.0.120.0050.00216.89
8.0.110.0030.00516.87
8.0.100.0000.00716.93
8.0.90.0030.00516.78
8.0.80.0130.00316.92
8.0.70.0000.00716.90
8.0.60.0040.00416.80
8.0.50.0020.00516.85
8.0.30.0140.00517.12
8.0.20.0100.01417.41
8.0.10.0050.00317.03
8.0.00.0130.00416.59
7.4.330.0030.00315.55
7.4.320.0000.00716.68
7.4.300.0060.00016.50
7.4.290.0060.00316.61
7.4.280.0070.00016.51
7.4.270.0070.00016.59
7.4.260.0000.00816.49
7.4.250.0040.00416.40
7.4.240.0070.00016.56
7.4.230.0030.00316.31
7.4.220.0060.01216.51
7.4.210.0090.00516.51
7.4.200.0030.00316.59
7.4.160.0060.01116.58
7.4.150.0110.00617.40
7.4.140.0090.01217.86
7.4.130.0120.00716.54
7.4.120.0120.00916.57
7.4.110.0110.00716.51
7.4.100.0110.00616.52
7.4.90.0130.00316.49
7.4.80.0070.01119.39
7.4.70.0140.01116.53
7.4.60.0130.00316.45
7.4.50.0060.00616.54
7.4.40.0040.01116.62
7.4.30.0100.00716.50
7.4.00.0080.00714.86
7.3.330.0020.00213.23
7.3.320.0030.00313.38
7.3.310.0030.00316.38
7.3.300.0070.00016.38
7.3.290.0000.00616.39
7.3.280.0080.00916.36
7.3.270.0110.00717.40
7.3.260.0090.00916.32
7.3.250.0090.01016.39
7.3.240.0120.00616.46
7.3.230.0040.01316.36
7.3.210.0060.01016.41
7.3.200.0000.01716.48
7.3.190.0070.00716.35
7.3.180.0040.01216.47
7.3.170.0090.00916.61
7.3.160.0030.01316.66
7.3.120.0100.00615.02
7.3.110.0070.00814.85
7.3.100.0040.00815.01
7.3.90.0050.00714.89
7.3.80.0100.00414.93
7.3.70.0020.01114.90
7.3.60.0100.00514.88
7.3.50.0020.01114.76
7.3.40.0020.01114.66
7.3.30.0050.00914.89
7.3.20.0090.00516.81
7.3.10.0060.00716.47
7.3.00.0080.00816.70
7.2.330.0130.00716.42
7.2.320.0100.00616.62
7.2.310.0100.01016.78
7.2.300.0130.01016.52
7.2.290.0060.01216.72
7.2.250.0090.00915.00
7.2.240.0030.01714.90
7.2.230.0040.00915.25
7.2.220.0030.00815.18
7.2.210.0100.00514.86
7.2.200.0030.00915.06
7.2.190.0020.01315.15
7.2.180.0060.00915.00
7.2.170.0050.01114.98
7.2.160.0070.00715.26
7.2.150.0110.00317.12
7.2.140.0000.01017.04
7.2.130.0080.00916.79
7.2.120.0110.00916.66
7.2.110.0160.00716.65
7.2.100.0100.00816.74
7.2.90.0070.00916.81
7.2.80.0080.00716.83
7.2.70.0060.00916.88
7.2.60.0050.00616.74
7.2.50.0080.00716.73
7.2.40.0120.00517.02
7.2.30.0090.01217.02
7.2.20.0120.00816.89
7.2.10.0110.01016.77
7.2.00.0050.01117.62
7.1.330.0060.00815.84
7.1.320.0060.00615.60
7.1.310.0090.00516.14
7.1.300.0030.00815.70
7.1.290.0100.00515.74
7.1.280.0090.00515.78
7.1.270.0020.01315.71
7.1.260.0100.00315.86
7.1.250.0120.00515.66
7.1.200.0080.00415.71
7.1.100.0060.00617.98
7.1.70.0000.00717.26
7.1.60.0530.02333.23
7.1.50.0500.01732.96
7.1.40.3930.01732.65
7.1.30.0530.01332.66
7.1.20.0500.01032.70
7.1.10.0570.00714.54
7.1.00.0400.01314.72
7.0.200.0330.01314.73
7.0.190.0430.01714.82
7.0.180.0330.01314.47
7.0.170.0500.00314.27
7.0.160.0370.01014.50
7.0.150.0500.00714.37
7.0.140.0530.00714.79
7.0.130.0570.01014.54
7.0.120.0430.02014.53
7.0.110.0300.01314.56
7.0.100.0330.01014.41
7.0.90.0370.00714.66
7.0.80.0430.01314.63
7.0.70.0470.00314.54
7.0.60.0330.01014.51
7.0.50.0400.01014.59
7.0.40.0430.01014.76
7.0.30.0400.01714.81
7.0.20.0400.01714.63
7.0.10.0400.02014.59
7.0.00.0570.00714.69

preferences:
52.08 ms | 401 KiB | 5 Q