Remove image tags from a content

0 votes
110 views
asked Jan 31 in Laravel by anonymous
How can I remove the image tags from a paragraph of text?

3 Answers

0 votes
answered Jan 31 by Syam
<?
    $content = "this is something with an <img src=\"test.png\"/> in it.";
    $content = preg_replace("/<img[^>]+\>/i", "(image) ", $content);
    echo $content;
?>
0 votes
answered Jan 31 by anonymous
$text = '<p>Test paragraph.</p><!-- Comment --> <a href="#fragment">Other text</a>';
echo strip_tags($text); 
// output : Test paragraph. Other text

// Note: Allow <p> and <a>
echo strip_tags($text, '<p><a>'); 
// output - <p>Test paragraph.</p> <a href="#fragment">Other text</a>

Refer http://php.net/manual/en/function.strip-tags.php
0 votes
answered Jan 31 by anonymous
This is very simple.

Its on laravel blade, you can do it with CSS.

Related questions

+2 votes
2 answers 2846 views
0 votes
1 answer 173 views
0 votes
1 answer 216 views
0 votes
1 answer 346 views
0 votes
0 answers 43 views
asked Feb 13 in Laravel by Simply
+1 vote
1 answer 187 views
asked Dec 7, 2016 in Laravel by Pinto
...