Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8683987
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T22:10:59+00:00 2026-06-12T22:10:59+00:00

This is a popular snippet to compress multiple CSS with PHP. <?php header(‘Content-type: text/css’);

  • 0

This is a popular snippet to compress multiple CSS with PHP.

 <?php
      header('Content-type: text/css');
      ob_start("compress");
      function compress($buffer) {
        /* remove comments */
        $buffer = preg_replace('!/\*[^*]*\*+([^/][^*]*\*+)*/!', '', $buffer);
        /* remove tabs, spaces, newlines, etc. */
        $buffer = str_replace(array("
    ", "\r", "\n", "\t", '  ', '    ', '    '), '', $buffer);
        return $buffer;
      }

      /* your css files */
      include('master.css');
      include('typography.css');
      include('grid.css');
      include('print.css');
      include('handheld.css');

      ob_end_flush();
?>

Looking at the code, I can see that it will only compress the files, but will not combine them. How do I tweak it to combine the files too?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T22:11:01+00:00Added an answer on June 12, 2026 at 10:11 pm

    Have you tried the code? I’m pretty sure it combines it as well. It does the following: it sets a callback function to replace comments, tabs spaces and newlines. Then, it includes multiple CSS files (which all go through the same callback).

    In the end, the output is flushed to the browser. That would mean all CSS of all those files will be sent to the browser, which means it combines it as well.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This popular Stack Overflow question explained why CSS selectors are parsed right to left.
I'm using this popular approach for autoresizing content in UITableViewCell. And it's not working.
I have found this popular PHP/MySQL Script called Zip Location by SaniSoft and it
I am trying to recreate this popular jQuery lambda closure with CoffeeScript: (function($, window,
I know this question is very popular Asked here PHP: strtotime is returning false
I have this quite popular problem, but have failed to find a solution that
I know this question is overly popular, but I find nothing that addresses rewriting
Often with very popular videos I see a ridiculous view count. See this video
I'm currently trying to get the most popular productID from my MSSQL Database. This
I know this exception is pretty popular for SL and WCF developers since I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.