Consider a html page which having several comments; which is not good for mobile webpages, as its size must be very low. So better rebuild the html page.

Here a script written using php, where it removes the html comments (including the matter inside <!-- and -->

single line code for that


$str = preg_replace('/<!--*?-->/i', '', $str);

Category : | Read More...... edit post

2 Response to "how to remove html comments using php style"

  1. Reenu Saxena Said,

    Thank you for this code.It will help me to build my site.
    Acai Berry

     

  2. Anonymous Said,

    didnt work for me, use

    preg_replace('/))*.-->/i', '', $html);

     

Post a Comment

Followers

FeedCount

Latest Posts

thecoderinc

Subscribe Now