View Full Version : removing html tags

11-03-2009, 08:50 PM
Hi experts ! i am trying to remove html tags around my html file.
example code:

<p>This is an image </p>
<img src="http://image.info/200910/186336.jpg" border="0" alt="" /><br /><br />

when i use strip_tags it will remove everything and i will have only "This is an image" text left, is it possible that i can display the image link and it will sounded like this:

[img]http://image.info/200910/186336.jpg[/ img]

so in my code it will display the paragraph with image below. Thanks for any support

11-03-2009, 09:03 PM
strip_tags() will remove the HTML.

look in to BBCODE for the other purpose. i'll post some sample bb in a second

function bb_code($text)
"" => "<b>",
"" => "</b>",
"" => "<i>",
"" => "</i>",
":)" => "<img src='img/smilies/smile.gif' />",
"" => "<img src='",
"" => "' />"

// etc

$bb_text= str_replace(array_keys($array), array_values($array), $text);

return $bb_text;


that is if i understand you right

11-03-2009, 09:35 PM
Thank you for taking time to look at my problem but this never did the trick, what i did is here. all html is in $content.

$content = str_ireplace($replacing, "*****", $content);
$content = strip_tags($content, '<img>');
$patterns = '<img>';
$replacement ='[img]';
$content = preg_replace($patterns, $replacement, $content);

but again not result what i wanted, its not diplaying the images its showing code like this:

<[img] src="http://image.info/200910/186336.jpg" border="0" alt="" />
I know i need to use some regular expressions there but i am not so familiar with it.
Thanks for any help

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum