note 10595 deleted from function.str-pad by sander
| From: | sander@php.net | Date: | Fri, 03 May 2002 20:30:05 +0000 |
| Subject: | note 10595 deleted from function.str-pad by sander | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-30145@lists.php.net to get a copy of this message | ||
str_pad for earlier Versions:
$pm....string to pad
$lt....desired length
$pw....charakter to pad with
$dn....direction
-> 0..from the left
-> 1..from the right
-> 2..from both sides
function str_pd($pm, $lt, $pw, $dn){
$cnt = $lt - strlen($pm);
$for($i=0;$i<$cnt;$i++){
switch($dn){
case 2:
$i%2?$pm=$pw.$pm:$pm=$pm.$pw;
break;
case 1:
$pm=$pm.$pw;
break;
default:
$pm=$pw.$pm;
break;
}
}
return $pm;
}