From 58634c046869454b074417a80cf5e35761ec9e8e Mon Sep 17 00:00:00 2001 From: Jason Woofenden Date: Mon, 25 Apr 2011 01:50:57 -0400 Subject: [PATCH] enc_tab indents empty lines --- encode.php | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/encode.php b/encode.php index 7afae37..4ef72ae 100644 --- a/encode.php +++ b/encode.php @@ -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) { -- 1.7.10.4