Go Back   CodingForums.com > :: Server side development > PHP > Post a PHP snippet

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 08-23-2009, 09:34 PM   PM User | #1
Phil Jackson
Senior Coder

 
Join Date: Aug 2009
Location: Mansfield, Nottinghamshire, UK
Posts: 1,547
Thanks: 57
Thanked 148 Times in 147 Posts
Phil Jackson is on a distinguished road
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..
Phil Jackson is offline   Reply With Quote
Old 08-23-2009, 09:58 PM   PM User | #2
_Aerospace_Eng_
Supreme Master coder!


 
_Aerospace_Eng_'s Avatar
 
Join Date: Dec 2004
Location: In a place far, far away...
Posts: 19,293
Thanks: 2
Thanked 1,044 Times in 1,020 Posts
_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light
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!||||
_Aerospace_Eng_ is offline   Reply With Quote
Old 08-24-2009, 07:12 AM   PM User | #3
Phil Jackson
Senior Coder

 
Join Date: Aug 2009
Location: Mansfield, Nottinghamshire, UK
Posts: 1,547
Thanks: 57
Thanked 148 Times in 147 Posts
Phil Jackson is on a distinguished road
it doesn't matter at all, its just to show the output.
Phil Jackson is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 06:59 AM.


Advertisement
Log in to turn off these ads.