From: Jason Woofenden Date: Mon, 25 Apr 2011 05:50:57 +0000 (-0400) Subject: enc_tab indents empty lines X-Git-Url: https://jasonwoof.com/gitweb/?p=wfpl.git;a=commitdiff_plain;h=58634c046869454b074417a80cf5e35761ec9e8e enc_tab indents empty lines --- 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) {