note 10595 added to str_pad
| From: | kno at aon dot at | Date: | Thu, 11 Jan 2001 21:27:31 +0000 |
| Subject: | note 10595 added to str_pad | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-9667@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;
}
http://www.php.net/manual/de/function.str-pad.php