3v4l.org

run code in 300+ PHP versions simultaneously
<?php $text = '[My Test URL|https://ww w.mywebsite.c om/t est?param=123]'; echo preg_replace_callback('/\[([^][|]*)\|([^][]+)]/', function($m) { return '<a href="' . str_replace(' ', '', $m[2]) . '">' . $m[1] . '</a>'; }, $text);

preferences:
32.46 ms | 405 KiB | 5 Q