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/>
CodePudding user response:
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.