
How to remove P tag from CkEditor in Laravel?
How to remove P tag from CkEditor in Laravel?
Hello everyone, in this post we will look at how to solve "How to remove P tag from CkEditor in Laravel?" in programming.
I am getting data from users and storing them into a database using ckeditor but I've noticed that for text, it adds `<p>` and `</p>` around the text. How can i remove this p tag after getting data from ckeditor before storing into the database in Laravel.-
Remove <p>, </p> tag from HTML using preg_replace()
//Get data using request $text = $request->ckeditor_data; $text = preg_replace("/^<p.*?>/", "",$text); $text = preg_replace("|</p>$|", "",$text);
It will remove only
<p>, </p>
tags surrounding the whole text. Like if you have HTML code<p>Lorem</p><p>Ipsum</p>
then it will return it will return "Lorem</p><p>Ipsum
". -
Remove all <p>, </p> tags from HTML using strip_tags()
$input = $request->ckeditor_data; $data = strip_tags($input);
If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.
Don't forget to share this article! Help us spread the word by clicking the share button below.
We appreciate your support and are committed to providing you valuable and informative content.
We are thankful for your never ending support.
Random Code Snippet Queries: Laravel
- Use withCount() to Calculate Child Relationship Records
- How to increment column value of table in Laravel
- File_put_contents(/var/www/html/w3code/storage/framework/sessions/CXwN3EXKxERD6jgy3rADcaAAbAx8FRKih2JK7UO9): Failed to open stream: Permission denied
- Pass variable from blade to controller Laravel
- Comment .env file in laravel
- How to add a key value pair to existing array in laravel
- Method chaining in Laravel
- Get count of filter data, while return a small set of records
- SQLSTATE[42S21]: Column already exists: 1060 Duplicate column name 'user_id'
- How to get last year records count with month wise in Laravel
- How to pass external link in laravel blade to anchor tag
- How to check relationship is loaded or not in Laravel
- How to upload multiple images after preview in laravel using cropper js
- How to send email in laravel
- How to use or operator in laravel
- How to prevent host header attack in Laravel
- How to add dynamic page title in Laravel view
- Global scope in Laravel with example
- How to get random string in Laravel
- Laravel API response format
- How to display HTML tags In Laravel blade
- Laravel insert query not working
- Call to a member function update() on null
- Extract only time from datetime in laravel
- SQLSTATE[HY000]: General error: 1215 Cannot add foreign key constraint