RE: [PHP] link on user uploaded pic
| From: | Brad Fuller | Date: | Thu, 29 Mar 2007 17:24:12 +0000 |
| Subject: | RE: [PHP] link on user uploaded pic | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-251650@lists.php.net to get a copy of this message | ||
> -----Original Message-----
> From: Tana [mailto:tana@devtux.hu]
> Sent: Thursday, March 29, 2007 1:02 PM
> To: php-general@lists.php.net
> Subject: [PHP] link on user uploaded pic
>
> Hi
>
> which is the best way to change this code
>
> <img src="images/user_upload/akarmi.jpg">
>
> to
>
> <a href="images/user_upload/bp_akarmi.jpg"><img
> src="images/user_upload/akarmi.jpg"></a>
>
> in html ?
>
>
> ----------------------------
> Tana
<?php
$imgTag = '<img src="images/user_upload/akarmi.jpg">';
echo preg_replace('/<img src="images\/user_upload\/(.*?)">/', '<a
href="images/user_upload/bp_$1"><img
src="images/user_upload/$1"></a>',
$imgTag);
?>
-B