Inside this article we will see the concept i.e Laravel How To Remove HTML Tags From String Tutorial Example. Article contains the classified information about How to remove HTML tags from data in Laravel.
We will use a PHP Function for this i.e PHP strip_tags() Function. The strip_tags() function strips a string from HTML, XML, and PHP tags.
Read More: Laravel 9 How To Parse Date Format Example Tutorial
Let’s get started.
Laravel Installation
Open terminal and run this command to create a laravel project.
composer create-project laravel/laravel myblog
It will create a project folder with name myblog inside your local system.
To start the development server of laravel –
php artisan serve
URL: http://127.0.0.1:8000
Assuming laravel already installed inside your system.
How To Remove HTML Tags From Blade File
Open project into terminal and run this command.
$ php artisan make:controller DemoController
It will create a DemoController.php file inside /app/Http/Controllers folder.
Read More: Laravel 9 Count Working Days Between Two Dates Example
Open file and write this code into it.
<?php namespace App\Http\Controllers; use Illuminate\Http\Request; class DemoController extends Controller { public function index() { $tagsString = "Hi, Welcome To Online Web Tutor. <h1>Nice</h1>, Nice to <p>meet</p> you."; return view("demo", compact("tagsString")); } }
Next,
Create Blade Template File
Create a file demo.blade.php inside /resources/views folder.
Open view file and write this code into it.
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>Laravel How To Remove HTML Tags From String Tutorial</title> </head> <body> <h3>Laravel How To Remove HTML Tags From String Tutorial</h3> {{ strip_tags($tagsString) }} </body> </html>
Output
We hope this article helped you to learn Laravel How To Remove HTML Tags From String Tutorial in a very detailed way.
Read More: Laravel 9 Count Weekends Days Between Two Dates Example
Online Web Tutor invites you to try Skillshike! Learn CakePHP, Laravel, CodeIgniter, Node Js, MySQL, Authentication, RESTful Web Services, etc into a depth level. Master the Coding Skills to Become an Expert in PHP Web Development. So, Search your favourite course and enroll now.
If you liked this article, then please subscribe to our YouTube Channel for PHP & it’s framework, WordPress, Node Js video tutorials. You can also find us on Twitter and Facebook.