Vky Vky - 11 months ago 41
HTML Question

remove html code after a certain character php

Question: I have full html code inserted into mysql database. I want to remove everything after

Product Description
. How would I do it?

<p>hjfsdgfsgdfjsdgfjgdsjfgsdjgfjsdgf </p>
<p>Product Description</p>

I want to store into the database again with the html format.


Answering to the question proposed in the comments of your original question, you can do something like this:

preg_replace("/<div class=\"ui-box product-description-main\".*/sm", " ",$your_html_goes_here);

This removes everything after the div element with classes 'ui-box' and 'product-description-main'.

By the same token, answering your original question is fairly simple:

preg_replace("/(<p>Product Description<\/p>).*/sm", "$1", $your_html_goes_here);

This removes everything after the paragraph 'Product Description'. If you need more information about the regex proposed in my answer,let me know.