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 "Iteration $i:\n"; echo "Memory usage: " . memory_get_usage() . "\n"; 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 = [range(1, 1000), [range(1, 512), 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.0.10.0150.01217.34
8.0.00.0090.01717.49
7.4.290.0030.00616.91
7.4.140.0120.01516.75
7.4.130.0080.01316.72
7.4.120.0110.01416.80
7.4.110.0140.01416.82
7.4.100.0070.02016.86
7.4.90.0070.01716.90
7.4.80.0220.00416.79
7.4.70.0120.01516.73
7.4.60.0120.01516.46
7.4.50.0040.02216.68
7.4.40.0210.00416.82
7.4.30.0160.01016.73
7.4.20.0130.01016.55
7.4.10.0070.01716.60
7.4.00.0180.01416.77
7.3.260.0130.01316.70
7.3.250.0140.00716.72
7.3.240.0110.01416.70
7.3.230.0180.00916.79
7.3.220.0070.01416.68
7.3.210.0130.00916.82
7.3.200.0120.01116.78
7.3.190.0140.01016.53
7.3.180.0120.01516.50
7.3.170.0170.00716.52
7.3.160.0070.01716.40
7.3.150.0180.00616.79
7.3.140.0370.00316.48
7.3.130.0140.01116.54
7.3.120.0200.00716.55
7.3.110.0150.00716.34
7.3.100.0120.01216.61
7.3.90.0170.00716.48
7.3.80.0220.00716.47
7.3.70.0230.00316.55
7.3.60.0090.01916.32
7.3.50.0130.01116.72
7.3.40.0230.00516.32
7.3.30.0150.01216.60
7.3.20.0280.00016.64
7.3.10.0210.00816.66
7.3.00.0090.01816.58

preferences:
31.88 ms | 403 KiB | 5 Q