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.00.0090.00917.86
7.4.140.0090.00917.86
7.4.130.0070.01117.86
7.4.120.0100.01017.86
7.4.110.0120.01117.86
7.4.100.0160.00517.86
7.4.90.0150.00617.86
7.4.80.0070.01417.86
7.4.70.0240.01217.86
7.4.60.0180.00417.86
7.4.50.0110.01117.86
7.4.40.0110.01117.86
7.4.30.0160.00817.86
7.4.20.0180.00617.86
7.4.10.0040.02117.86
7.4.00.0060.01417.86
7.3.260.0140.00617.86
7.3.250.0070.01117.86
7.3.240.0070.01317.86
7.3.230.0110.00717.86
7.3.220.0050.01517.86
7.3.210.0150.00617.86
7.3.200.0210.00017.86
7.3.190.0230.00517.86
7.3.180.0150.00517.86
7.3.170.0030.01817.86
7.3.160.0150.00617.86
7.3.150.0200.00317.86
7.3.140.0050.01617.86
7.3.130.0140.00917.86
7.3.120.0110.01117.86
7.3.110.0080.01417.86
7.3.100.0140.00917.86
7.3.90.0120.01217.86
7.3.80.0190.00317.86
7.3.70.0090.01717.86
7.3.60.0090.01417.86
7.3.50.0040.02217.86
7.3.40.0110.01117.86
7.3.30.0140.01017.86
7.3.20.0150.01317.86
7.3.10.0230.00617.86
7.3.00.0120.01517.86

preferences:
45.27 ms | 400 KiB | 5 Q