3v4l.org

run code in 300+ PHP versions simultaneously
<?php $i = 0; function is_cyclic(array &$array) { global $i; // Exit when too deep. if (++$i > 10) exit; echo "Call $i:\n"; var_dump($array); echo "\n"; $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)) { //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(); is_cyclic($bomb);

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.140.0050.00316.58
8.3.130.0030.00618.34
8.3.120.0040.01218.90
8.3.110.0040.00420.94
8.3.100.0070.01416.66
8.3.90.0060.00926.77
8.3.80.0100.00019.36
8.3.70.0160.00018.56
8.3.60.0120.00316.61
8.3.50.0070.01024.47
8.3.40.0180.00418.92
8.3.30.0060.00918.89
8.3.20.0050.00324.18
8.3.10.0040.00424.66
8.3.00.0000.00826.16
8.2.250.0040.00420.41
8.2.240.0030.00618.71
8.2.230.0090.00022.58
8.2.220.0060.01224.06
8.2.210.0040.00426.77
8.2.200.0090.00018.88
8.2.190.0040.01116.61
8.2.180.0000.01525.92
8.2.170.0130.00318.91
8.2.160.0170.00322.96
8.2.150.0080.00025.66
8.2.140.0000.01424.66
8.2.130.0040.00426.16
8.2.120.0000.00821.18
8.2.110.0060.00322.20
8.2.100.0000.01119.28
8.2.90.0000.00820.48
8.2.80.0060.00320.22
8.2.70.0050.00317.75
8.2.60.0000.00917.75
8.2.50.0040.00417.63
8.2.40.0040.00418.22
8.2.30.0000.01018.01
8.2.20.0040.00418.13
8.2.10.0040.00419.34
8.2.00.0030.00619.17
8.1.300.0100.01017.92
8.1.290.0100.00030.84
8.1.280.0180.00025.92
8.1.270.0040.00423.99
8.1.260.0080.00026.35
8.1.250.0040.00428.09
8.1.240.0060.00323.83
8.1.230.0030.00720.97
8.1.220.0050.00317.74
8.1.210.0040.00418.88
8.1.200.0030.00617.35
8.1.190.0040.00417.22
8.1.180.0060.00318.10
8.1.170.0030.00718.66
8.1.160.0050.00518.84
8.1.150.0040.00418.77
8.1.140.0000.00818.88
8.1.130.0000.00717.46
8.1.120.0040.00417.36
8.1.110.0050.00317.34
8.1.100.0060.00317.46
8.1.90.0030.00417.47
8.1.80.0000.00717.36
8.1.70.0000.00717.35
8.1.60.0030.00617.48
8.1.50.0030.00617.54
8.1.40.0080.00017.48
8.1.30.0030.00517.64
8.1.20.0050.00617.62
8.1.10.0030.00517.57
8.1.00.0080.00017.50
8.0.300.0080.00020.12
8.0.290.0040.00416.75
8.0.280.0040.00418.50
8.0.270.0030.00318.07
8.0.260.0040.00416.90
8.0.250.0040.00417.01
8.0.240.0040.00417.07
8.0.230.0000.01017.04
8.0.220.0000.00816.90
8.0.210.0030.00316.82
8.0.200.0050.00316.88
8.0.190.0070.00016.98
8.0.180.0040.00416.86
8.0.170.0040.00416.93
8.0.160.0030.00416.91
8.0.150.0040.00416.76
8.0.140.0070.00016.78
8.0.130.0030.00313.48
8.0.120.0040.00416.83
8.0.110.0080.00016.95
8.0.100.0030.00516.95
8.0.90.0040.00417.02
8.0.80.0070.00816.88
8.0.70.0000.00716.90
8.0.60.0000.00716.85
8.0.50.0040.00416.73
8.0.30.0150.00317.17
8.0.20.0090.00917.22
8.0.10.0270.01217.10
8.0.00.0270.01517.04
7.4.330.0020.00215.55
7.4.320.0070.00016.57
7.4.300.0000.00716.55
7.4.290.0050.00216.45
7.4.280.0030.00616.64
7.4.270.0100.00016.52
7.4.260.0000.00716.51
7.4.250.0050.00316.49
7.4.240.0020.00516.59
7.4.230.0040.00416.41
7.4.220.0000.00716.45
7.4.210.0090.00716.64
7.4.200.0070.00016.67
7.4.140.0260.01316.55
7.4.130.0280.01116.66
7.4.120.0260.01116.55
7.4.110.0220.01616.42
7.4.100.0300.00816.52
7.4.90.0400.00016.47
7.4.80.0190.02016.45
7.4.70.0260.01516.39
7.4.60.0310.01116.66
7.4.50.0240.01816.45
7.4.40.0300.01016.57
7.4.30.0300.01116.50
7.4.20.0160.02416.31
7.4.10.0300.01016.46
7.4.00.0120.00916.57
7.3.330.0000.00916.46
7.3.320.0000.00613.45
7.3.310.0000.00716.31
7.3.300.0000.00716.45
7.3.290.0040.01116.40
7.3.260.0130.01216.67
7.3.250.0310.00916.47
7.3.240.0190.02016.54
7.3.230.0290.01116.34
7.3.220.0230.01616.43
7.3.210.0310.00916.38
7.3.200.0320.00616.58
7.3.190.0300.01216.38
7.3.180.0350.00616.54
7.3.170.0330.00716.46
7.3.160.0320.00716.50
7.3.150.0360.00716.48
7.3.140.0290.00416.56
7.3.130.0260.00916.54
7.3.120.0280.01216.40
7.3.110.0210.01216.29
7.3.100.0290.00516.39
7.3.90.0300.00316.63
7.3.80.0270.00916.39
7.3.70.0360.00616.56
7.3.60.0190.02316.53
7.3.50.0230.01716.20
7.3.40.0260.01016.30
7.3.30.0300.00816.49
7.3.20.0210.01616.52
7.3.10.0340.01016.26
7.3.00.0390.00716.41

preferences:
39.89 ms | 403 KiB | 5 Q