3v4l.org

run code in 300+ PHP versions simultaneously
<?php $text = "[spoiler]Test\ntesting[/spoiler]."; $text = preg_replace_callback("(\[spoiler\](.*?)\[\/spoiler\])is", function($match){ $lines = explode("\n", str_rot13($match[1])); foreach ($lines as &$line) { if ($line != "") $line = "[spoiler]".$line."[/spoiler]"; } unset($line); $output = implode($lines); return $output; }, $text ); echo $text; ?>

preferences:
26.48 ms | 402 KiB | 5 Q