Topic: replace part of string.
if i have a string like this
"this is some text and this [img]http://url_to_image[/img] is an image".
how can i replace the part
"[img]http://url_to_image[/img]"
with
<a href='http://url_to_image' target='_blank' border='0'><img src='http://url_to_image' width='100'></a>"
or
<a href='http://url_to_image' target='_blank' border='0'><img src='http://url_to_image' height='100'></a>"
if the width is bigger then the height, i want to put width='100',
if the height is bigger then the width, i want to put height='100',
i know i can do that with getimagesize
i tried something like this to determine whether i have to use width or height:
$image = 'http://localhost/users/images/top.jpg';
list($w, $h) = getimagesize($image);
echo "<a href=".$image." target='_blank'><img src=".$image." border='0' ";
if ($w > $h) {
echo "width='100'>";
}
if ($h > $w) {
echo "height='100'>";
}
echo "</a>";
i know this works...i just don't know how to replace that part of the string..(like what i described above.
thank you