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.60.0160.00618.43
8.3.50.0100.01016.29
8.3.40.0160.00618.96
8.3.30.0120.00318.83
8.3.20.0080.00024.18
8.3.10.0080.00024.66
8.3.00.0040.00426.16
8.2.180.0190.00325.92
8.2.170.0150.00018.97
8.2.160.0190.00322.96
8.2.150.0040.00425.66
8.2.140.0120.00624.66
8.2.130.0140.00426.16
8.2.120.0130.00626.35
8.2.110.0100.00020.53
8.2.100.0060.00619.95
8.2.90.0050.00317.75
8.2.80.0040.00418.91
8.2.70.0040.00417.61
8.2.60.0000.00817.75
8.2.50.0000.00818.05
8.2.40.0030.00618.34
8.2.30.0040.00418.14
8.2.20.0000.00818.18
8.2.10.0040.00419.36
8.2.00.0050.00219.19
8.1.280.0110.01125.92
8.1.270.0100.00023.99
8.1.260.0030.00628.09
8.1.250.0030.00528.09
8.1.240.0070.00322.14
8.1.230.0110.00020.96
8.1.220.0050.00317.74
8.1.210.0050.00318.77
8.1.200.0060.00317.35
8.1.190.0040.00417.35
8.1.180.0080.00018.10
8.1.170.0000.00818.54
8.1.160.0000.00718.89
8.1.150.0060.00318.84
8.1.140.0080.00018.80
8.1.130.0000.00719.25
8.1.120.0070.00017.34
8.1.110.0080.00017.39
8.1.100.0040.00417.35
8.1.90.0030.00517.37
8.1.80.0040.00817.43
8.1.70.0030.00317.51
8.1.60.0030.00617.52
8.1.50.0000.00817.54
8.1.40.0080.00017.40
8.1.30.0040.00417.61
8.1.20.0040.00417.61
8.1.10.0090.00017.62
8.1.00.0000.00817.51
8.0.300.0000.00918.92
8.0.290.0000.00816.63
8.0.280.0000.00718.45
8.0.270.0030.00318.13
8.0.260.0000.00716.76
8.0.250.0040.00716.93
8.0.240.0080.00016.89
8.0.230.0050.00217.01
8.0.220.0000.00716.96
8.0.210.0000.00716.93
8.0.200.0000.00716.99
8.0.190.0050.00317.04
8.0.180.0040.00417.02
8.0.170.0040.00416.81
8.0.160.0070.00017.04
8.0.150.0040.00416.76
8.0.140.0090.00316.89
8.0.130.0000.00613.39
8.0.120.0000.00816.83
8.0.110.0000.00816.99
8.0.100.0040.00416.92
8.0.90.0040.00416.98
8.0.80.0050.01116.94
8.0.70.0000.00716.76
8.0.60.0000.00716.92
8.0.50.0070.00017.02
8.0.30.0050.01417.13
8.0.20.0070.01417.17
8.0.10.0030.00617.07
8.0.00.0160.00917.86
7.4.330.0060.00015.55
7.4.320.0000.00716.65
7.4.300.0050.00316.61
7.4.290.0040.00416.52
7.4.280.0040.00416.55
7.4.270.0040.00416.48
7.4.260.0030.00313.30
7.4.250.0000.00816.48
7.4.240.0040.00416.54
7.4.230.0070.00016.69
7.4.220.0030.00316.43
7.4.210.0110.00716.51
7.4.200.0040.00416.70
7.4.140.0070.01017.86
7.4.130.0030.01517.86
7.4.120.0130.00817.86
7.4.110.0070.01317.86
7.4.100.0110.00717.86
7.4.90.0220.00917.86
7.4.80.0070.01017.86
7.4.70.0070.01017.86
7.4.60.0100.00717.86
7.4.50.0040.01717.86
7.4.40.0060.01317.86
7.4.30.0040.01417.86
7.4.20.0060.01217.86
7.4.10.0080.01117.86
7.4.00.0190.00017.86
7.3.330.0050.00216.29
7.3.320.0000.00613.25
7.3.310.0000.00716.46
7.3.300.0030.00316.43
7.3.290.0110.00416.42
7.3.260.0120.00917.86
7.3.250.0120.00917.86
7.3.240.0150.00617.86
7.3.230.0090.00917.86
7.3.220.0080.01217.86
7.3.210.0120.00917.86
7.3.200.0100.00717.86
7.3.190.0110.00617.86
7.3.180.0160.00317.86
7.3.170.0100.01017.86
7.3.160.0140.00317.86
7.3.150.0100.01017.86
7.3.140.0080.01117.86
7.3.130.0070.01117.86
7.3.120.0110.00717.86
7.3.110.0110.00817.86
7.3.100.0180.00017.86
7.3.90.0090.00917.86
7.3.80.0150.00317.86
7.3.70.0100.00717.86
7.3.60.0140.00317.86
7.3.50.0140.00317.86
7.3.40.0100.00917.86
7.3.30.0060.01017.86
7.3.20.0580.00317.86
7.3.10.0100.01017.86
7.3.00.0030.01417.86

preferences:
48.77 ms | 400 KiB | 5 Q