I have the following code being echoed:
I only want the img
tag to be echoed.
I’ve tried using <?php echo strip_tags($value, '<img>'); ?>
but because the tag isn’t actually a proper HTML tag I don’t know how to remove it. Is there a function which will remove the text from a string?
Would str_replace
work?
usually, regular expression is not recommended for HTML parsing. But if you just want something quick, you can use:
output:
Try
You could, however, change the
[]
with<>
and then do thestrip_tags
try some regexp :
http://www.php.net/manual/en/function.preg-replace.php
something like that something should work with minimum adaptation (i don’t work with PHP since a long long long time xD) :