PHP – strip_tags() Replace with Spaces Example

Hey Developer,

In this guide, we are going to learn php strip tag with space. you will learn php strip_tags replace with space. In this article, we will implement a php strip_tags() replace with spaces example. This article will give you a simple example of php laravel strip_tags should replace with spaces. So, let us dive into the details.

we will use strip_tags() function just removed all html tags from string in php. but if you want to remove html tag and add space there so you can count words or what ever task you can do it. so here, i will give you simple example to strip_tags() replace with spaces in php.

Example:

index.php

<?php
  
    $string = "<p>Hello Developer.</p><p>How are you?</p>
              <table>
              <tr><td>Table Column One</td><td>Table Column Two</td></tr>
              </table>";
    
    $string = str_replace('><', '> <', $string);
    $newString = strip_tags($string);
  
    var_dump($newString);
      
?>

Output:

string(112) "Hello Developer. How are you? Table Column One Table Column Two "

I hope it can help you…

Leave a Comment

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

Scroll to Top