3v4l.org

run code in 300+ PHP versions simultaneously
<?php function is_cyclic(array &$array, int $maxDepth = -1) { if ($maxDepth === 0) { throw new Exception('Maximum nesting level exceeded.'); } $lastKey = array_key_last($array); if ($lastKey === null) { // Array is empty return false; } static $marker; if ($marker === null) $marker = new stdClass(); if ($array[$lastKey] === $marker) { return true; } $array[] = $marker; foreach ($array as &$item) { if (is_array($item) && is_cyclic($item, $maxDepth - 1)) { array_pop($array); return true; } } array_pop($array); return false; } function craft_bomb() { $array = [1, [2, 3]]; $array[1][1] = &$array; return $array; } $bomb = craft_bomb(); var_export(is_cyclic($bomb, 10));

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.0110.01118.80
8.3.50.0060.01016.47
8.3.40.0160.00618.97
8.3.30.0150.00018.80
8.3.20.0180.00024.18
8.3.10.0070.01124.66
8.3.00.0000.00826.16
8.2.180.0120.00325.92
8.2.170.0090.00619.13
8.2.160.0120.00322.96
8.2.150.0150.00325.66
8.2.140.0080.00024.66
8.2.130.0150.00426.16
8.2.120.0150.00426.35
8.2.110.0090.01220.96
8.2.100.0080.00417.84
8.2.90.0050.00317.88
8.2.80.0000.00818.86
8.2.70.0090.00017.75
8.2.60.0000.00817.80
8.2.50.0080.00018.05
8.2.40.0050.00218.22
8.2.30.0030.00618.03
8.2.20.0000.00718.01
8.2.10.0000.00719.30
8.2.00.0000.00819.22
8.1.280.0170.00325.92
8.1.270.0130.00623.99
8.1.260.0060.00328.09
8.1.250.0030.00528.09
8.1.240.0090.00317.48
8.1.230.0040.00717.83
8.1.220.0060.00317.74
8.1.210.0030.00518.77
8.1.200.0030.00617.48
8.1.190.0000.00817.38
8.1.180.0050.00318.10
8.1.170.0060.00318.59
8.1.160.0040.00418.91
8.1.150.0060.00318.77
8.1.140.0000.00718.81
8.1.130.0030.00320.18
8.1.120.0050.00217.46
8.1.110.0030.00617.50
8.1.100.0040.00417.51
8.1.90.0040.00417.37
8.1.80.0070.00017.36
8.1.70.0070.00017.36
8.1.60.0080.00017.59
8.1.50.0040.00417.52
8.1.40.0080.00417.42
8.1.30.0060.00317.68
8.1.20.0040.00417.68
8.1.10.0000.00817.57
8.1.00.0040.00417.39
8.0.300.0040.00418.78
8.0.290.0080.00016.75
8.0.280.0030.00318.38
8.0.270.0030.00318.16
8.0.260.0000.00618.51
8.0.250.0030.00716.91
8.0.240.0050.00317.00
8.0.230.0070.00017.04
8.0.220.0000.00816.96
8.0.210.0030.00316.85
8.0.200.0000.00817.07
8.0.190.0040.00417.03
8.0.180.0080.00017.05
8.0.170.0040.00417.00
8.0.160.0070.00017.02
8.0.150.0020.00516.92
8.0.140.0080.00416.86
8.0.130.0030.00313.44
8.0.120.0080.00017.02
8.0.110.0040.00416.80
8.0.100.0000.00717.08
8.0.90.0000.00716.84
8.0.80.0080.00717.00
8.0.70.0000.00716.86
8.0.60.0000.00717.03
8.0.50.0000.00816.97
8.0.30.0070.01017.24
8.0.20.0060.01216.94
8.0.10.0000.00717.12
8.0.00.0160.00317.86
7.4.330.0020.00215.55
7.4.320.0060.00016.60
7.4.300.0030.00516.55
7.4.290.0080.00016.46
7.4.280.0040.00416.52
7.4.270.0070.00016.46
7.4.260.0060.00013.28
7.4.250.0050.00216.45
7.4.240.0030.00316.38
7.4.230.0030.00516.62
7.4.220.0000.00716.50
7.4.210.0080.00716.60
7.4.200.0070.00016.36
7.4.140.0090.00917.86
7.4.130.0160.00617.86
7.4.120.0030.01517.86
7.4.110.0160.00317.86
7.4.100.0100.00717.86
7.4.90.0170.00017.86
7.4.80.0160.00017.86
7.4.70.0150.00417.86
7.4.60.0130.01017.86
7.4.50.0040.01517.86
7.4.40.0100.01017.86
7.4.30.0140.00717.86
7.4.20.0160.00317.86
7.4.10.0080.01217.86
7.4.00.0110.00717.86
7.3.330.0040.00416.27
7.3.320.0030.00313.25
7.3.310.0030.00316.25
7.3.300.0000.00716.39
7.3.290.0030.01116.38
7.3.260.0110.00517.86
7.3.250.0040.01317.86
7.3.240.0150.00317.86
7.3.230.0090.00917.86
7.3.220.0100.00717.86
7.3.210.0070.01117.86
7.3.200.0080.01017.86
7.3.190.0180.00317.86
7.3.180.0100.00717.86
7.3.170.0130.00717.86
7.3.160.0080.01317.86
7.3.150.0090.00917.86
7.3.140.0090.00917.86
7.3.130.0040.01617.86
7.3.120.0170.00017.86
7.3.110.0050.01417.86
7.3.100.0090.00917.86
7.3.90.0080.00917.86
7.3.80.0140.00917.86
7.3.70.0160.00817.86
7.3.60.0060.01317.86
7.3.50.0090.01317.86
7.3.40.0120.01217.86
7.3.30.0260.02917.86
7.3.20.0100.01017.86
7.3.10.0160.00417.86
7.3.00.0130.00717.86

preferences:
33.74 ms | 400 KiB | 5 Q