3v4l.org

run code in 300+ PHP versions simultaneously
<?php function modern_strtok(string $string, string $delim): \Generator { $pos = 0; while (true) { $pos += \strspn($string, $delim, $pos); $len = \strcspn($string, $delim, $pos); if (!$len) return; $delim = (yield \substr($string, $pos, $len)) ?? $delim; $pos += $len; } } $string = ' -- This -- is an example -string '; $delim = ' -'; foreach (modern_strtok($string, $delim) as $tok) { var_dump($tok); } echo "************\n"; // changing $delim mid-course for ($g = modern_strtok($string, $delim); $g->valid(); $g->send($delim)) { var_dump($g->current()); $delim = ' '; }

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.0080.00817.25
8.3.130.0080.00018.66
8.3.120.0040.00420.61
8.3.110.0030.00620.94
8.3.100.0000.01524.06
8.3.90.0300.01026.77
8.3.80.0400.00026.77
8.3.70.0260.00326.77
8.3.60.0220.00026.77
8.3.50.0180.00426.77
8.3.40.0110.00726.77
8.3.30.0160.00326.77
8.3.20.0120.00626.77
8.3.10.0170.00026.77
8.3.00.0190.00326.77
8.2.250.0000.00818.27
8.2.240.0040.00418.95
8.2.230.0050.00322.58
8.2.220.0080.01137.54
8.2.210.0090.00326.77
8.2.200.0210.00026.77
8.2.190.0150.00626.77
8.2.180.0130.00426.77
8.2.170.0210.00026.77
8.2.160.0170.00626.77
8.2.150.0140.00726.77
8.2.140.0210.00026.77
8.2.130.0230.00026.77
8.2.120.0220.00026.77
8.2.110.0160.00826.77
8.2.100.0110.00726.77
8.2.90.0190.00026.77
8.2.80.0150.00626.77
8.2.70.0120.00626.77
8.2.60.0190.00026.77
8.2.50.0180.00326.77
8.2.40.0060.01126.77
8.2.30.0080.00826.77
8.2.20.0140.00326.77
8.2.10.0070.01026.77
8.2.00.0170.00026.77
8.1.300.0130.00318.29
8.1.290.0180.00026.77
8.1.280.0140.00526.77
8.1.270.0140.00626.77
8.1.260.0150.00426.77
8.1.250.0120.00826.77
8.1.240.0110.00626.77
8.1.230.0190.00026.77
8.1.220.0140.00326.77
8.1.210.0170.00026.77
8.1.200.0160.00326.77
8.1.190.0110.00626.77
8.1.180.0100.01026.77
8.1.170.0130.00426.77
8.1.160.0160.01026.77
8.1.150.0110.00626.77
8.1.140.0080.00826.77
8.1.130.0140.00226.77
8.1.120.0130.00326.77
8.1.110.0150.00326.77
8.1.100.0160.00026.77
8.1.90.0160.01026.77
8.1.80.0110.00626.77
8.1.70.0160.00226.77
8.1.60.0120.00626.77
8.1.50.0220.00026.77
8.1.40.0140.00526.77
8.1.30.0090.00926.77
8.1.20.0190.00026.77
8.1.10.0160.00426.77
8.1.00.0090.00926.77

preferences:
42.39 ms | 403 KiB | 5 Q