[ create a new paste ] login | about

Link: http://codepad.org/UIh0zCJj    [ raw code | output | fork ]

PHP, pasted on Jun 21:
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);
?>


Output:
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" />


Create a new paste based on this one


Comments: