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

3 Answers

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

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

Related questions

0 votes
1 answer 1.5k views
0 votes
2 answers 5.6k views
asked Jul 17, 2018 in General by anonymous
+2 votes
2 answers 9.1k views
0 votes
0 answers 2.8k views
0 votes
1 answer 2.0k views
0 votes
1 answer 1.5k views
...