PHP - strip_tags() Replace with Spaces Example
Hey Dev,
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>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:
string(98) "First word. Second words.
First Column Second Column"
I hope it can help you...
Hardik Savani
I'm a full-stack developer, entrepreneur and owner of ItSolutionstuff.com. I live in India and I love to write tutorials and tips that can help to other artisan. I am a big fan of PHP, Laravel, Angular, Vue, Node, Javascript, JQuery, Codeigniter and Bootstrap from the early stage. I believe in Hardworking and Consistency.
We are Recommending you
- How to Get Last Word from String in PHP?
- How to Get First Word from String in PHP?
- How to Remove Last 2, 3, 4, 5, 7 Characters of a String in PHP?
- How to Get Last 2, 3, 4, 5, 7 Characters of a String in PHP?
- PHP String Count Specific Character Example
- PHP Get First 2, 3, 4, 5, 10 Character from String Example
- How to Remove Numbers from String in PHP?
- PHP Ajax Multiple Image Upload with Preview Example
- How to Get Folder Path from File Path in PHP?
- How to Remove White Space from String in PHP?
- How to Get the File Size in PHP?
- How to Convert Object into Array in PHP?
- How to Find Day Name from Specific Date in PHP?