3v4l.org

run code in 500+ PHP versions simultaneously
<?php function array_search_range( mixed $needle, array $haystack, int $offset = 0, ?int $length = null, bool $strict = false, ): int|string|false { if ( $offset < 0 ) { $offset = count($haystack) + $offset; } if ( $length < 0 ) { $length = count($haystack) + $length - $offset; } $currentOffset = -1; foreach ( $haystack as $key => $value ) { $currentOffset++; if ( $currentOffset < $offset ) { continue; } if ( $length !== null && $currentOffset >= $offset + $length ) { break; } if ( ( $strict && $value === $needle ) || ( ! $strict && $value == $needle ) ) { return $key; } } return false; } $items = ['zero', 'one', 'two', 'target', 'four', 'target']; $key = array_search_range('target', $items, 2, 3, true); var_dump($key); // int(3) $items = ['zero', 'one', 'two', 'target', 'four', 'target']; $key = array_search_range('target', $items, 4, null, true); var_dump($key); // int(5) $items = ['zero', 'one', 'two', 'target', 'four', 'target']; $key = array_search_range('target', $items, 1, 2, true); var_dump($key); // bool(false) $items = ['zero', 'one', 'two', 'target', 'four', 'target']; $key = array_search_range('target', $items, 1, -3, true); var_dump($key); // bool(false)

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.5.90.0420.00816.71
8.5.80.0330.01116.62
8.5.70.0400.00616.73
8.5.60.0330.00716.85
8.5.50.0270.00516.70
8.5.40.0360.00516.55
8.5.30.0300.00616.70
8.5.20.0210.00816.43
8.5.10.0250.00916.53
8.5.00.0110.00416.11
8.4.240.0220.00519.47
8.4.230.0160.00518.91
8.4.220.0170.00419.34
8.4.210.0140.00419.55
8.4.200.0180.00319.61
8.4.190.0180.00519.36
8.4.180.0250.00319.63
8.4.170.0170.00419.43
8.4.160.0170.00419.32
8.4.150.0140.00519.63
8.4.140.0150.00517.72
8.4.130.0160.00317.58
8.4.120.0130.00617.69
8.4.110.0210.00917.66
8.4.100.0240.01217.62
8.4.90.0260.01117.68
8.4.80.0280.01017.73
8.4.70.0210.00517.65
8.4.60.0200.00317.66
8.4.50.0160.00517.71
8.4.40.0210.00217.61
8.4.30.0170.00617.62
8.4.20.0190.00217.42
8.4.10.0190.00417.46
8.3.330.0190.00518.25
8.3.320.0130.00718.20
8.3.310.0160.00418.26
8.3.300.0130.00618.34
8.3.290.0140.00718.04
8.3.280.0140.00518.31
8.3.270.0170.00216.65
8.3.260.0150.00616.65
8.3.250.0170.00316.51
8.3.240.0180.00416.42
8.3.230.0150.00616.65
8.3.220.0180.00416.35
8.3.210.0190.00316.56
8.3.200.0160.00416.52
8.3.190.0120.00916.54
8.3.180.0180.00316.66
8.3.170.0140.00716.67
8.3.160.0170.00416.57
8.3.150.0170.00416.59
8.3.140.0140.00616.56
8.3.130.0150.00316.51
8.3.120.0170.00216.35
8.3.110.0130.00616.52
8.3.100.0170.00516.87
8.3.90.0200.00316.64
8.3.80.0170.00416.59
8.3.70.0200.00516.46
8.3.60.0150.00616.36
8.3.50.0170.00316.65
8.3.40.0160.00617.85
8.3.30.0150.00317.78
8.3.20.0130.00817.98
8.3.10.0160.00418.01
8.3.00.0120.00517.96
8.2.330.0330.00717.71
8.2.320.0160.00717.98
8.2.310.0160.00618.02

preferences:
56.28 ms | 779 KiB | 5 Q