• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

The Programming Expert

Solving All of Your Programming Headaches

  • HTML
  • JavaScript
  • jQuery
  • PHP
  • Python
  • SAS
  • Ruby
  • About
You are here: Home / PHP / Remove HTML Tags from String in php

Remove HTML Tags from String in php

April 4, 2022 Leave a Comment

To remove all HTML tags from a string in php, the easiest way is to use the strip_tags() function.

strip_tags() tries to return a string with all NULL bytes, HTML and php tags remove from a given string.

We can get rid of the HTML tags in a string by simply passing a string to strip_tags().

Below is a simple example of getting stripping the HTML tags from a string in php with strip_tags().

$string_with_html_tags = "<p>I'm a string with <span>HTML</span>!</p>";

echo strip_tags($string_with_html_tags, "<p>");

//Output:
<p>I'm a string with HTML!</p>

Hopefully this article has been useful for you to learn how to use the strip_tags() function to remove HTML tags from a string in php.

Other Articles You'll Also Like:

  • 1.  How to Create an Empty Array in php
  • 2.  Capitalize First Letter of String with php ucfirst() Function
  • 3.  Get Days in Month Using php
  • 4.  Remove Last Character from String Using php
  • 5.  php array_slice() – Get Slice of Elements from Array
  • 6.  Remove First Character from String Using php
  • 7.  Replace Space with Dash in php String
  • 8.  php trim() Function – Remove Whitespace at Beginning and End of String
  • 9.  Delete Cookie Using php
  • 10.  php print_r() Function- Get Information about Variables in php

About The Programming Expert

The Programming Expert is a compilation of a programmer’s findings in the world of software development, website creation, and automation of processes.

Programming allows us to create amazing applications which make our work more efficient, repeatable and accurate.

At the end of the day, we want to be able to just push a button and let the code do it’s magic.

You can read more about us on our about page.

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Primary Sidebar

About The Programming Expert

the programming expert main image

Welcome to The Programming Expert. We are a group of US-based programming professionals who have helped companies build, maintain, and improve everything from simple websites to large-scale projects.

We built The Programming Expert to help you solve your programming problems with useful coding methods and functions in various programming languages.

Search

Learn Coding from Experts on Udemy

Looking to boost your skills and learn how to become a programming expert?

Check out the links below to view Udemy courses for learning to program in the following languages:

Copyright © 2023 · The Programming Expert · About · Privacy Policy