note 38259 rejected from function.sprintf by pollita
| From: | pollita@php.net | Date: | Sun, 14 Dec 2003 04:57:56 +0000 |
| Subject: | note 38259 rejected from function.sprintf by pollita | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-61926@lists.php.net to get a copy of this message | ||
Note Submitter: fie@myrealbox.com
----
function pad_text($str,$howmuch,$with,$side=""){
if($side=="LEFT"||$side==""){
for($i=strlen($str);$i<$howmuch;$i++){
$str = $with.$str;
}
return $str;
}
if($side=="RIGHT"){
for($i=strlen($str);$i<$howmuch;$i++){
$str = $str.$with;
}
return $str;
}
}
I thing there should be a padding function by itself.
here is a function i wrote to pad binary numbers with the decbin function.
pad_text(string string,integer pad length,string pad character,[string side to pad]);
The fourth, optional, variable is either set to LEFT or RIGHT. If nothing is set then it is assumed
to pad the LEFT side.