How to Remove HTML Tags from String in Laravel?
Hello Friends,
Here, I will show you how to work laravel remove html tags from string. you can understand a concept of how to remove html tags in laravel. It's a simple example of how to remove html tags from string in laravel. I’m going to show you about remove html tags from string in laravel controller. you will do the following things for laravel remove html tags from string example.
You can use this example with laravel 6, laravel 7, laravel 8, laravel 9, laravel 10 and laravel 11 versions.
If you want to remove all HTML tags from the string then we can use strip_tags() function of php. i will give you a simple example code with output for how to remove HTML tags from strings in laravel application. so let's see the bellow code of the controller file and blade file:
app/Http/Controllers/DemoController.php
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class DemoController extends Controller
{
/**
* Write code on Method
*
* @return response()
*/
public function index(Request $request)
{
$tagsString = "Google <h1>Nice</h1>, Nice to <p>meet</p> you.";
return view("demo", compact("tagsString"));
}
}
views/demo.blade.php
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title></title>
</head>
<body>
<h1>How to Remove HTML Tags from String in Laravel? - ItSolutionStuff.com</h1>
{{ strip_tags($tagsString) }}
</body>
</html>
Output:
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
- Laravel Delete File After Download Response Example
- Laravel Carbon Count Weekends Days Between Two Dates Example
- Laravel Carbon Parse Date Format Example
- Laravel Change Mail Driver Dynamically Example
- How to set CC And BCC Email Address In Laravel Mail?
- How to Call Controller Function in Blade Laravel?
- Laravel Blade @includeWhen and @includeUnless Example
- Laravel Blade @unless Directive Example
- How to Generate Random Unique String in Laravel?
- How to Generate Route with Query String in Laravel?
- How to Add Query String Automatically on Laravel Pagination Links?
- How to Get Query Strings Value in Laravel?