Insert below the CSS, that you want to be formatted :




    

\n"; echo "\nResult:"; if(isset($sendcss1)){ echo "\n ... using formatting method 1 ...\n"; } if(isset($sendcss2)){ echo "\n ... using formatting method 2 ...\n"; } echo "\n
\n"; echo "\n
\n"; $cleancss=$csstext; include_once('csstidy/class.csstidy.php'); include_once('csstidy/class.csstidy_print.php'); $css = new csstidy(); $css->set_cfg('preserve_css',true); if(isset($sendcss1)){ $css->load_template("format1.tpl", true); } if(isset($sendcss2)){ $css->load_template("format2.tpl", true); } $css->parse($csstext); $p=new csstidy_print($css); $cleancss=$p->formatted(); if(isset($sendcss2)){ $res=explode("\n",$cleancss); $out=""; $maxpos=0; foreach($res as $line){ $bracketpos=strpos($line,"{"); if($bracketpos){ if($maxpos<$bracketpos)$maxpos=$bracketpos; } } foreach($res as $line){ $bracketpos=strpos($line,"{"); if($bracketpos){ $first=substr($line,0,$bracketpos); $rest=substr($line,$bracketpos,100); $line=$first; $newbpos=4*(($maxpos/4)+1); for($i=$newbpos;$i>($bracketpos % $newbpos);$i--){ $line.=' '; } $line.=$rest; } $out.=$line."\n"; } $cleancss=$out; } echo ""; } ?>