Strip img or HTML tag from HTML

Friday, April 6, 2012

print this page
send email

While i was woking with Joomla Easy Blog ran into a problem where i have to get image/image link from the DB result in which all of the blog content was mixed.I used below method for that after a long session with regx and all.Happy coding. And for sure regx never helped me

$html = $row->text;
$base_url = JURI::root();
// $dom->load('test.html'); // if in a file
$dom->loadHTML($html); // if in a string

for ($i=0;
$i++) {
$sam = $dom->getElementsByTagName('img')->item($i)->getAttribute('src');
echo $base_url$sam ;//use this for image source




Post a Comment