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

3 Answers

0 votes
answered by
<?
    $content = "this is something with an <img src=\"test.png\"/> in it.";
    $content = preg_replace("/<img[^>]+\>/i", "(image) ", $content);
    echo $content;
?>
0 votes
answered by
$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 by
This is very simple.

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

Related questions

0 votes
2 answers 2k views
+2 votes
2 answers 5.3k views
0 votes
0 answers 1.2k views
0 votes
1 answer 947 views
0 votes
1 answer 533 views
...