3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Node { private $key, $kids; public function __construct(string $key, ?Node $parent = null) { if ($parent !== null) $parent->kids[$key] = $this; $this->key = $key; } public function match(array $parts): ?self { if (empty($parts)) return $this; $part = array_shift($parts); if (isset($this->kids[$part])) return $this->kids[$part]->match($parts); else return null; } public function getKey(): string { return $this->key; } } /* * root * |-- foo * `-- bar * `-- baz */ $root = new Node(""); $foo = new Node("foo", $root); $bar = new Node("bar", $root); $baz = new Node("baz", $bar); $node = $root->match(explode("/", "bar/baz")); if ($node !== null) echo $node->getKey();

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.0100.01016.63
8.3.50.0040.01116.36
8.3.40.0150.00718.79
8.3.30.0100.00318.70
8.3.20.0090.00020.19
8.3.10.0050.00323.70
8.3.00.0040.00421.91
8.2.180.0120.00916.38
8.2.170.0060.00922.96
8.2.160.0110.00720.32
8.2.150.0080.00024.18
8.2.140.0000.00824.66
8.2.130.0080.00022.09
8.2.120.0040.00426.35
8.2.110.0000.01020.53
8.2.100.0040.00718.22
8.2.90.0080.00018.34
8.2.80.0000.00917.97
8.2.70.0000.00817.93
8.2.60.0040.00418.22
8.2.50.0040.00418.10
8.2.40.0040.00420.52
8.2.30.0080.00021.00
8.2.20.0000.00918.01
8.2.10.0040.00418.14
8.2.00.0000.00717.96
8.1.280.0150.00325.92
8.1.270.0000.00824.02
8.1.260.0040.00426.35
8.1.250.0000.00928.09
8.1.240.0060.00620.76
8.1.230.0030.01021.03
8.1.220.0040.00417.78
8.1.210.0050.00318.79
8.1.200.0000.01217.23
8.1.190.0000.00917.23
8.1.180.0030.00518.10
8.1.170.0000.00818.70
8.1.160.0040.00418.90
8.1.150.0040.00418.86
8.1.140.0000.00719.55
8.1.130.0000.00718.91
8.1.120.0030.00617.35
8.1.110.0030.00517.42
8.1.100.0040.00417.43
8.1.90.0070.00017.45
8.1.80.0000.00717.40
8.1.70.0000.00717.29
8.1.60.0090.00017.59
8.1.50.0000.00717.51
8.1.40.0000.00917.55
8.1.30.0000.00917.70
8.1.20.0000.00817.68
8.1.10.0050.00317.61
8.1.00.0050.00317.42
8.0.300.0030.00619.79
8.0.290.0050.00416.63
8.0.280.0040.00418.39
8.0.270.0030.00517.19
8.0.260.0000.00716.88
8.0.250.0000.00716.88
8.0.240.0000.00816.87
8.0.230.0000.00816.90
8.0.220.0030.00316.79
8.0.210.0000.00716.88
8.0.200.0070.00016.78
8.0.190.0040.00416.94
8.0.180.0040.00416.79
8.0.170.0030.00516.77
8.0.160.0030.00516.77
8.0.150.0070.00016.78
8.0.140.0050.00216.80
8.0.130.0050.00013.23
8.0.120.0040.00416.84
8.0.110.0000.00716.86
8.0.100.0000.00716.70
8.0.90.0070.00016.89
8.0.80.0030.01316.76
8.0.70.0080.00016.92
8.0.60.0050.00216.89
8.0.50.0000.00716.89
8.0.30.0070.01116.95
8.0.20.0110.00817.40
8.0.10.0040.00316.98
8.0.00.0070.01016.97
7.4.330.0000.00516.82
7.4.320.0000.00716.65
7.4.300.0000.00716.54
7.4.290.0040.00416.47
7.4.280.0040.00416.61
7.4.270.0050.00216.52
7.4.260.0080.00016.50
7.4.250.0040.00416.39
7.4.240.0060.00316.54
7.4.230.0080.00016.52
7.4.220.0090.00916.57
7.4.210.0080.00816.62
7.4.200.0040.00416.44
7.4.160.0110.00716.57
7.4.150.0150.00317.40
7.4.140.0090.01117.86
7.4.130.0070.01116.50
7.4.120.0080.01216.50
7.4.110.0070.01016.43
7.4.100.0110.00616.36
7.4.90.0130.00316.48
7.4.80.0000.01719.39
7.4.70.0070.01616.42
7.4.60.0130.00316.58
7.4.50.0070.00716.55
7.4.40.0120.00616.65
7.4.30.0130.00316.43
7.4.00.0000.01014.75
7.3.330.0000.00513.36
7.3.320.0060.00013.46
7.3.310.0000.00716.25
7.3.300.0030.00316.38
7.3.290.0100.00316.40
7.3.280.0080.00716.34
7.3.270.0110.00717.40
7.3.260.0100.01016.35
7.3.250.0080.01016.49
7.3.240.0060.01116.60
7.3.230.0080.00816.63
7.3.210.0070.01016.36
7.3.200.0130.00416.54
7.3.190.0140.00416.73
7.3.180.0040.01616.34
7.3.170.0080.00816.39
7.3.160.0070.01016.65
7.2.330.0150.00616.61
7.2.320.0100.01016.77
7.2.310.0090.00916.82
7.2.300.0030.01416.73
7.2.290.0110.00516.64
7.2.60.0090.00616.77
7.1.200.0100.00315.58
7.1.110.0100.00318.16
7.1.100.0140.00018.06
7.1.90.0040.00918.19
7.1.80.0000.01217.86
7.1.70.0100.00317.10
7.1.60.0170.02034.99
7.1.50.0250.01234.76
7.1.40.0210.01834.28
7.1.30.0130.01634.67
7.1.20.0210.00734.73
7.1.10.0070.00716.41
7.1.00.0030.01016.59
7.0.250.0060.00617.55
7.0.240.0040.01117.82
7.0.230.0030.01017.63
7.0.220.0000.01117.60
7.0.210.0060.00616.55
7.0.200.0030.01416.69
7.0.190.0040.01116.25
7.0.180.0060.00915.93
7.0.170.0060.00916.14
7.0.160.0030.01016.07
7.0.150.0000.01416.07
7.0.140.0080.00616.00
7.0.130.0070.00716.44
7.0.120.0070.00716.48
7.0.110.0030.01016.20
7.0.100.0030.01016.28
7.0.90.0030.00916.32
7.0.80.0080.00816.30
7.0.70.0030.00916.00
7.0.60.0100.00315.73
7.0.50.0030.01016.23
7.0.40.0000.01316.25
7.0.30.0060.00616.32
7.0.20.0100.00316.47
7.0.10.0080.00416.33
7.0.00.0060.00616.17

preferences:
58.79 ms | 400 KiB | 5 Q