3v4l.org

run code in 300+ PHP versions simultaneously
<?php $sources = [ "{img:amp.jpg}", "{img:amp.jpg alt:something}", "{img:amp.jpg alt:something width:10 height:11}", ]; foreach ($sources as $str) { $str = str_replace(['{', '}', ':', 'img'], ['', '', '="', 'src'], $str); echo sprintf( '<img %s>', implode(" ", array_map(function($a){return $a . '"';}, explode(' ', $str))) ) . PHP_EOL; }

preferences:
25.53 ms | 408 KiB | 5 Q