Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Senior Coder
    Join Date
    Aug 2009
    Location
    Mansfield, Nottinghamshire, UK
    Posts
    1,555
    Thanks
    57
    Thanked 148 Times in 147 Posts

    remove comments from CSS

    Hi I have loads of snippets from my plug n play CMS but heres a small one.


    PHP Code:
    <?php
    function removeComments ($address
    {
    $style file_get_contents($address); 

    if(
    preg_match("#\/\*((?!\*\/).)*#is"$style))
    {
        
    $style preg_replace("#\/\*((?!\*\/).)*#is"""$style);
        
    $style str_replace("*/"""$style);
    }
    return 
    "<xmp>".$style."</xmp>";
    }

    echo 
    removeComments("http://www.heartinternet.co.uk/styles/main.css"); 
    ?>
    Last edited by Phil Jackson; 08-23-2009 at 09:50 PM.

  • #2
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    So why are you using xmp and not pre? xmp is deprecated. I guess it really doesn't matter.
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • #3
    Senior Coder
    Join Date
    Aug 2009
    Location
    Mansfield, Nottinghamshire, UK
    Posts
    1,555
    Thanks
    57
    Thanked 148 Times in 147 Posts
    it doesn't matter at all, its just to show the output.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •