3v4l.org

run code in 300+ PHP versions simultaneously
<?php $string = '3-6,8,12,14-50'; $result = []; foreach (explode(',', $string) as $v) { $x = explode('-', $v); array_push($result, ...range($x[0], $x[1] ?? $v)); } var_export($result);
Output for 8.3.0 - 8.3.28, 8.4.1 - 8.4.14, 8.5.0
array ( 0 => '3', 1 => '4', 2 => '5', 3 => '6', 4 => '8', 5 => 12, 6 => 14, 7 => 15, 8 => 16, 9 => 17, 10 => 18, 11 => 19, 12 => 20, 13 => 21, 14 => 22, 15 => 23, 16 => 24, 17 => 25, 18 => 26, 19 => 27, 20 => 28, 21 => 29, 22 => 30, 23 => 31, 24 => 32, 25 => 33, 26 => 34, 27 => 35, 28 => 36, 29 => 37, 30 => 38, 31 => 39, 32 => 40, 33 => 41, 34 => 42, 35 => 43, 36 => 44, 37 => 45, 38 => 46, 39 => 47, 40 => 48, 41 => 49, 42 => 50, )
Output for 8.4.15
/bin/php-8.4.15: /usr/lib/libm.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libm.so.6: version `GLIBC_2.35' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libc.so.6: version `GLIBC_2.34' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libc.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.4.15)
Process exited with code 1.
Output for 7.4.0 - 7.4.33, 8.0.1 - 8.0.30, 8.1.0 - 8.1.33, 8.2.0 - 8.2.29
array ( 0 => 3, 1 => 4, 2 => 5, 3 => 6, 4 => 8, 5 => 12, 6 => 14, 7 => 15, 8 => 16, 9 => 17, 10 => 18, 11 => 19, 12 => 20, 13 => 21, 14 => 22, 15 => 23, 16 => 24, 17 => 25, 18 => 26, 19 => 27, 20 => 28, 21 => 29, 22 => 30, 23 => 31, 24 => 32, 25 => 33, 26 => 34, 27 => 35, 28 => 36, 29 => 37, 30 => 38, 31 => 39, 32 => 40, 33 => 41, 34 => 42, 35 => 43, 36 => 44, 37 => 45, 38 => 46, 39 => 47, 40 => 48, 41 => 49, 42 => 50, )

preferences:
159.32 ms | 411 KiB | 5 Q