...

remove comments from CSS

Phil Jackson
08-23-2009, 09:34 PM
Hi I have loads of snippets from my plug n play CMS but heres a small one.



<?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");
?>

_Aerospace_Eng_
08-23-2009, 09:58 PM
So why are you using xmp and not pre? xmp is deprecated. I guess it really doesn't matter.

Phil Jackson
08-24-2009, 07:12 AM
it doesn't matter at all, its just to show the output.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum