PHP – strip_tags() Replace with Spaces Example

Posted by

Upgrade & Secure Your Future with DevOps, SRE, DevSecOps, MLOps!

We spend hours scrolling social media and waste money on things we forget, but won’t spend 30 minutes a day earning certifications that can change our lives.
Master in DevOps, SRE, DevSecOps & MLOps by DevOps School!

Learn from Guru Rajesh Kumar and double your salary in just one year.


Get Started Now!

We are going to learn php strip tags with spaces. You will learn how to replace php Strip_tags with space. In this article, we will replace php Strip_tags() with a blank space example. This article will give you a simple example of PHP laravel replacing Strip_tags with spaces. So, let’s get into the details. We will use the strip_tags() function, simply removing all HTML tags from the string in PHP. But if you want to remove html tag and add space there so that you can count words or do any function. So here, I will give you simple example of replacing Strip_tags() with spaces in PHP.

Example : 1

<?php
  
    $string = "<p>First word.</p>
               <p>Second words.</p>
              <table>
                 <tr>
                   <td>First Column</td>
                   <td>Second Column</td>
                 </tr>
              </table>";
    
    $string = str_replace('><', '> <', $string);
    $newString = strip_tags($string);
  
    var_dump($newString);
      
?>

Output :

Leave a Reply

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

0
Would love your thoughts, please comment.x
()
x