PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Friday, July 8, 2022

[FIXED] How to remove specificly the last <p></p> tag in all posts in wordpress?

 July 08, 2022     paragraph, php, posts, tags, wordpress     No comments   

Issue

I want to remove the last paragraph of content in all of my posts, which always have a

tag on their own.

example: <p>content I want to keep</p> 
         <p>content I want to remove<p/>

Solution

You can work with Regex:

preg_grep('/<p\b[^>]*>(.*?)<\/p>/', explode('\n', $input_lines));

that will return an array with every line of <p>...</p>. Unset the last key of that array and then keep working with it.



Answered By - Dominic Poppe
Answer Checked By - Candace Johnson (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing