3v4l.org

run code in 300+ PHP versions simultaneously
<?php $html = ' [My Test URL 1|https://www.mywebsite.com/test?param=1] [My Test URL 2|https://www.mywebsite.com/test?param=2] [My Test URL 3|https://www.mywebsite.com/test?param=3] [My Test URL 4|https://www.mywebsite.com/test?param=4] '; echo preg_replace('/\[(.*?)[|](.*?)\]/', '<a href="$2">$1</a>', $html);

preferences:
159.26 ms | 404 KiB | 5 Q