Monday, 16 January 2017

Remove Image tag and html content from content in php


1.Actual Content with image 

$bodycontent = "<div id='testing'>Exmple body content and <img src=\"image/image.png\"/> image none.</div><div id='testing'>Exmple body content <img src=\"image/image.png\"/> image none.</div><div id='testing'>Exmple body content <img src=\"image/image.png\"/>image none.</div>";

2.Display only content in php tags

<?php
$bodycontent = preg_replace("/<img[^>]+\>/i", "", $bodycontent);
    $bodycontent = strip_tags($bodycontent);
  echo $bodycontent;
?>