1 2 3 4 5 6 7 8 9 10 11 12 13
<?php $template = <<<END Here's a picture of me skiing with friends: {{image-20-m}} And here's one of me programming: {{image-619-v}} END; echo preg_replace('/{{image-(\d+)-([mv])}}/', '<img src="$1.jpg" class="$2" />', $template); ?>
1 2 3 4 5 6 7
Here's a picture of me skiing with friends: <img src="20.jpg" class="m" /> And here's one of me programming: <img src="619.jpg" class="v" />