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.130.0080.00018.50
8.3.120.0030.00618.88
8.3.110.0130.00720.94
8.3.100.0060.00324.06
8.3.90.0090.00026.77
8.3.80.0030.00719.36
8.3.70.0090.00618.43
8.3.60.0140.00316.63
8.3.50.0100.00724.57
8.3.40.0110.00418.99
8.3.30.0070.00718.58
8.3.20.0040.00424.18
8.3.10.0050.00224.66
8.3.00.0030.00626.16
8.2.250.0040.00416.71
8.2.240.0060.00917.18
8.2.230.0030.00622.58
8.2.220.0000.00937.54
8.2.210.0040.00426.77
8.2.200.0090.00018.88
8.2.190.0150.00016.58
8.2.180.0090.00625.92
8.2.170.0090.00618.91
8.2.160.0170.00022.96
8.2.150.0040.00425.66
8.2.140.0000.00824.66
8.2.130.0040.00426.16
8.2.120.0040.00426.35
8.2.110.0030.00621.06
8.2.100.0090.00317.84
8.2.90.0060.00320.59
8.2.80.0030.00617.97
8.2.70.0030.00518.16
8.2.60.0000.00818.05
8.2.50.0090.00018.07
8.2.40.0000.00818.32
8.2.30.0090.00018.16
8.2.20.0000.00718.26
8.2.10.0040.00419.38
8.2.00.0000.00719.30
8.1.300.0050.00519.30
8.1.290.0060.00330.84
8.1.280.0070.01125.92
8.1.270.0040.00424.66
8.1.260.0070.00028.09
8.1.250.0040.00428.09
8.1.240.0110.00022.14
8.1.230.0100.00020.89
8.1.220.0080.00017.74
8.1.210.0030.00518.90
8.1.200.0090.00017.48
8.1.190.0060.00317.35
8.1.180.0000.00818.10
8.1.170.0000.01318.55
8.1.160.0040.00418.91
8.1.150.0040.00418.82
8.1.140.0000.00718.78
8.1.130.0050.00320.16
8.1.120.0000.00717.52
8.1.110.0040.00417.48
8.1.100.0060.00317.47
8.1.90.0030.00317.36
8.1.80.0040.00417.43
8.1.70.0070.00017.36
8.1.60.0040.00417.57
8.1.50.0030.00517.58
8.1.40.0040.00417.57
8.1.30.0030.00517.59
8.1.20.0000.01017.63
8.1.10.0000.00817.55
8.1.00.0080.00017.49
8.0.300.0030.00619.98
8.0.290.0000.00716.75
8.0.280.0050.00318.52
8.0.270.0070.00018.09
8.0.260.0030.00318.49
8.0.250.0050.00217.02
8.0.240.0070.00017.08
8.0.230.0100.00017.04
8.0.220.0040.00416.99
8.0.210.0070.00016.84
8.0.200.0050.00217.05
8.0.190.0080.00017.05
8.0.180.0040.00417.04
8.0.170.0050.00317.00
8.0.160.0070.00016.97
8.0.150.0040.00416.88
8.0.140.0030.00316.98
8.0.130.0030.00313.46
8.0.120.0000.00716.81
8.0.110.0040.00417.06
8.0.100.0040.00416.84
8.0.90.0050.00216.86
8.0.80.0070.01116.92
8.0.70.0040.00416.98
8.0.60.0080.00016.81
8.0.50.0000.00716.79
8.0.30.0070.01017.23
8.0.20.0120.00617.23
8.0.10.0420.00317.00
8.0.00.0310.01417.02
7.4.330.0030.00315.55
7.4.320.0000.00716.51
7.4.300.0030.00316.62
7.4.290.0030.00316.61
7.4.280.0070.00016.43
7.4.270.0050.00516.45
7.4.260.0030.00313.30
7.4.250.0050.00316.46
7.4.240.0000.00716.52
7.4.230.0000.00816.70
7.4.220.0000.00716.42
7.4.210.0080.00816.55
7.4.200.0040.00416.69
7.4.140.0210.02116.79
7.4.130.0320.00716.48
7.4.120.0340.00916.46
7.4.110.0290.01116.57
7.4.100.0340.00316.45
7.4.90.0350.00416.62
7.4.80.0270.01216.65
7.4.70.0240.01516.38
7.4.60.0270.01416.52
7.4.50.0340.00716.49
7.4.40.0250.01816.37
7.4.30.0240.01516.71
7.4.20.0280.01116.35
7.4.10.0350.00316.52
7.4.00.0280.01216.72
7.3.330.0050.00216.41
7.3.320.0000.00613.43
7.3.310.0030.00316.48
7.3.300.0000.00716.47
7.3.290.0120.00516.44
7.3.260.0110.01116.38
7.3.250.0310.00816.52
7.3.240.0330.00616.39
7.3.230.0310.00416.61
7.3.220.0270.01416.37
7.3.210.0310.01116.45
7.3.200.0280.01016.44
7.3.190.0310.01116.48
7.3.180.0300.00916.50
7.3.170.0260.01516.59
7.3.160.0350.00916.54
7.3.150.0390.00316.49
7.3.140.0250.01616.59
7.3.130.0240.01716.47
7.3.120.0260.01316.44
7.3.110.0240.01416.39
7.3.100.0240.01616.33
7.3.90.0280.00916.36
7.3.80.0290.01116.57
7.3.70.0280.01416.35
7.3.60.0290.01316.46
7.3.50.0320.01016.59
7.3.40.0240.01416.28
7.3.30.0240.01616.40
7.3.20.0380.00316.62
7.3.10.0310.01016.45
7.3.00.0280.01016.34

preferences:
45.67 ms | 403 KiB | 5 Q