JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
enc_tab indents empty lines
authorJason Woofenden <jason@jasonwoof.com>
Mon, 25 Apr 2011 05:50:57 +0000 (01:50 -0400)
committerJason Woofenden <jason@jasonwoof.com>
Mon, 25 Apr 2011 05:50:57 +0000 (01:50 -0400)
encode.php

index 7afae37..4ef72ae 100644 (file)
@@ -138,19 +138,12 @@ function enc_yesno($str) {
 }
 
 
-# add a tab at the begining of each non-empty line
+# add a tab at the begining of each line
 function enc_tab($str) {
-       $lines = explode("\n", $str);
-       $out = '';
-       foreach($lines as $line) {
-               if($line) {
-                       $out .= "\t$line";
-               }
-               $out .= "\n";
+       if('' . $str === '') {
+               return '';
        }
-
-       # remove the extra newline added above
-       return substr($out, 0, -1);
+       return "\t" . implode("\n\t", explode("\n", $str));
 }
 
 function enc_upper($str) {