3v4l.org

run code in 300+ PHP versions simultaneously
<?php $str = "helloworld"; echo preg_replace('~.\L.~', ' ', $str); echo "\n---\n"; echo array_reduce(str_split($str, 2), function($carry, $item) { return $carry . $item[0] . (isset($item[1]) ? ' ' : ''); }); echo "\n---\n"; for ($offset = 1, $length = strlen($str); $offset < $length; $offset += 2) { $str[$offset] = ' '; } echo $str;
Output for 8.1.32, 8.2.0 - 8.2.29, 8.3.0 - 8.3.28, 8.4.1 - 8.4.14, 8.5.0
Warning: preg_replace(): Compilation failed: PCRE2 does not support \F, \L, \l, \N{name}, \U, or \u at offset 3 in /in/JuJkJ on line 5 --- h l o o l --- h l o o l
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.

preferences:
36.01 ms | 407 KiB | 5 Q