programming faqs interview questions tech technical educational freshers guide preparation interviews hr telephonic
try another color:
try another fontsize: 60% 70% 80% 90%
ProgrammingFAQs

How to remove html tags from a string in php

We can do it in two ways i)

We can do it in two ways

i) using Regular Expressions

$message = ereg_replace('<[^>]+>', ' ', $message);

It replace all html tags with blank space

ii) using strip_tags function

syntax: string strip_tags ( string $str [, string $allowable_tags ] )

eg1: strip_tags($message);

it replaces all html tags with blank space

eg2: strip_tags($message, '< div>< img>');

It replaces all html tags with blank space except img and div tag