Consolidate RapidWeaver style sheets

Send Snippet To: Save this snippet to Code Collector Pro -- view all seydoggy's snippets
language: PHP
license: Other

Code for Snippet:

//get contents of buffer and discard
$out = ob_get_clean(); 
//split by newline
$arry_lines = split("[\n|\r]", $out);
//initialize vars
$beginStyleTag='<style type="text/css" media="all">';
//loop through each line of buffer
foreach ($arry_lines as &$value) {
   if (preg_match($pattern, $value)) {
        //found a css link
       //get the path to the css and then store the content of the css in var
        $filepath='./'.trim(str_replace('" />','',preg_replace($pattern,'$2$3$4', $value)));
        $file = file_get_contents($filepath, FILE_USE_INCLUDE_PATH);
        //inject style tags and css content into buffer
    else {
        //not a link, so just add to buffer
comments powered by Disqus


Link to this snippet:

Download to Code Collector

To use the direct link to your snippet on either copy the html from the above section or drag the Download to Code Collector to where you would like to use it.

More Info:

Times Viewed: 1085
Date Added: 2010-05-03 03:36:49
Last Modified: 0000-00-00 00:00:00

Web Analytics