3v4l.org

run code in 300+ PHP versions simultaneously
<?php function remove_after($needle, $haystack, $removeNeedle = false) { $needle = preg_quote($needle) . ($removeNeedle ? '' : '\K'); return preg_replace("#.*\K$needle.*#s", '', $haystack); } var_dump(remove_after("cheese", "The cheese is good and the cheese is yummy")); var_dump(remove_after("cheese", "The cheese is good and the cheese is yummy", true));
Output for 8.2.0 - 8.2.29, 8.3.0 - 8.3.28, 8.4.1 - 8.4.14, 8.5.0
string(33) "The cheese is good and the cheese" string(27) "The cheese is good and the "
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:
63.15 ms | 407 KiB | 5 Q