strip_tags – PHP remove custom tags

strip_tags() function is used to remove HTML and PHP tags from a string.

HTML comments and PHP tags are also removed.

It returns the stripped string.

<?php
$My_string =  ‘<p>This is example of paragraph</p>,
<div>This is an exmple of division,</div>
<p>This is another example of paragraph</p>,
<span>This is an example of span tag.</span>’;
$stripped_string = strip_tags($My_string);
echo $stripped_string;
?>

Output :
This is example of paragraph, This is an exmple of division, This is another example of paragraph, This is an example of span tag.

<?php
$My_string =  ‘<p>This is example of paragraph</p>,
<div>This is an exmple of division,</div>
<p>This is another example of paragraph</p>,
<span>This is an example of span tag.</span>’;
$stripped_string = strip_tags($My_string,'<div>’);
echo $stripped_string;
?>

Output :-
This is example of paragraph,

This is an exmple of division,

This is another example of paragraph, This is an example of span tag.

In above example,<div> is allowable tag, so it will return string with the <div> tag used.

Advertisements

I like to hear from you about this !!

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s