RE: link on user uploaded pic

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> -----Original Message-----
> From: Brad Fuller [mailto:bfuller@xxxxxxxxxxxxxxxx]
> Sent: Thursday, March 29, 2007 1:24 PM
> To: 'Tana'; php-general@xxxxxxxxxxxxx
> Subject: RE:  link on user uploaded pic
> 
> > -----Original Message-----
> > From: Tana [mailto:tana@xxxxxxxxx]
> > Sent: Thursday, March 29, 2007 1:02 PM
> > To: php-general@xxxxxxxxxxxxx
> > Subject:  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

Oops, in that last post part of that code is redundant (forgot about $0 ;)

<?php

$imgTag = '<img src="images/user_upload/akarmi.jpg">';

echo preg_replace('/<img src="images\/user_upload\/(.*?)">/', '<a
href="images/user_upload/bp_$1">$0</a>', $imgTag);

?>

Enjoy,

-B

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux