Welcome Guest, Not a member yet? Register   Sign In
HTML Output, Clean formatting
#6

[eluser]John_Betong[/eluser]
[quote author="Ian Jones" date="1264005605"]Not sure I understand what your post was John?

I need way to catch the output before heading to the browser, and have it properly indented so it appears cleanly formatted.[/quote]
 
Here is some code (from another poster) to remove all the spaces and line-feeds in your code. You can modify the code to suit your requirements:
Code:
$result = $this->load->view(ýour_view', $data, TRUE);

  $_SESSION['zzz_after']  = ''; // strlen $result);
  $_SESSION['zzz_before'] = strlen($result);
    
  $search = array
            (
               '/\>[^\S ]+/s', // strip whitespaces after tags, except space
               '/[^\S ]+\</s', // strip whitespaces before tags, except space
               '/(\s)+/s'      // shorten multiple whitespace sequences
             );

  $replace = array
             (
               '>',
               '<',
               '\\1'
             );
  $result = preg_replace($search, $replace, $result);
  
  $_SESSION['zzz_after'] = strlen($result);
                                                                                
  $result .= '<p> Source code reduced by:'
          .       sprintf('%6.3f', $_SESSION['zzz_after'] / $_SESSION['zzz_before'])
          .'% </p>';

   echo $result;
&nbsp;
&nbsp;
&nbsp;


Messages In This Thread
HTML Output, Clean formatting - by El Forum - 01-20-2010, 04:02 AM
HTML Output, Clean formatting - by El Forum - 01-20-2010, 04:24 AM
HTML Output, Clean formatting - by El Forum - 01-20-2010, 04:40 AM
HTML Output, Clean formatting - by El Forum - 01-20-2010, 05:07 AM
HTML Output, Clean formatting - by El Forum - 01-20-2010, 05:19 AM
HTML Output, Clean formatting - by El Forum - 01-20-2010, 06:08 AM
HTML Output, Clean formatting - by El Forum - 01-20-2010, 07:24 AM
HTML Output, Clean formatting - by El Forum - 01-20-2010, 03:52 PM
HTML Output, Clean formatting - by El Forum - 01-20-2010, 04:12 PM
HTML Output, Clean formatting - by El Forum - 01-20-2010, 07:42 PM
HTML Output, Clean formatting - by El Forum - 01-20-2010, 09:39 PM
HTML Output, Clean formatting - by El Forum - 01-20-2010, 09:40 PM
HTML Output, Clean formatting - by El Forum - 01-20-2010, 10:26 PM



Theme © iAndrew 2016 - Forum software by © MyBB