CSS Assembler and Compressor

  1. function assemble_css($css) {
  2.   // Initialize the output.
  3.   $output = '';
  4.   // Iterate through all the statements
  5.   foreach ($css as $statement) {
  6.     // Add the keys.
  7.     $output .= implode(",\n", $statement['keys']);
  8.     // And, the opening curly brace.
  9.     $output .= " {\n";
  10.     // Iterate through all the statements.
  11.     foreach ($statements as $key => $value) {
  12.       $output .= "  " . $key . ": " . $value . "\n";
  13.     }
  14.     // Add the closing curly brace.
  15.     $output .= "}\n";
  16.   }
  17.   // Return the output.
  18.   return $output;
  19. }
  20.  
  21. function compress_css($css) {
  22.   // Initialize the output.
  23.   $output = '';
  24.   // Iterate through all the statements
  25.   foreach ($css as $statement) {
  26.     // Add the keys.
  27.     $output .= implode(",", $statement['keys']);
  28.     // And, the opening curly brace.
  29.     $output .= "{";
  30.     // Iterate through all the statements.
  31.     foreach ($statements as $key => $value) {
  32.       $output .= $key . ":" . $value;
  33.     }
  34.     // Add the closing curly brace.
  35.     $output .= "}";
  36.   }
  37.   // Return the output.
  38.   return $output;
  39. }