3v4l.org

run code in 300+ PHP versions simultaneously
<?php $text = "*After Cesar had reported this, he\r\n jumped into his UFO and flew to space*\r\nStory goes on ... with some text.\r\n*Another section with\r\na linefeed within asterisks*"; echo preg_replace_callback('~\*[^*]*\*~', function($x) { return str_replace(["\r","\n"], '', $x[0]); }, $text);

preferences:
68.93 ms | 402 KiB | 5 Q