3v4l.org

run code in 300+ PHP versions simultaneously
<?php $text = "Hello <img src='https://example.com/image1.jpg'> , <img src='example.com/image2.jpg'> and now you :)"; $str = preg_replace('/<img[^>]*src=([\'"])(.*?)\1>/', "{#img='$2', alt=''}", $text); echo $str;

preferences:
37.86 ms | 404 KiB | 5 Q