Mailinglisten-Archive |
> function new_length($string, $length, $filler=' ') {
> $stringArray = explode('', $string);
> $length--;
> $newString = NULL;
>
> for($i=0; $i<=$length; $i++) {
> if(isset($stringArray[$i])) {
> $newString .= $stringArray[$i];
> } else {
> $newString .= substr($filler, 0, 1);
> }
> }
>
> return $newString;
> }
Das ginge auch so:
function str_set($string, $length, $filler=' ', $typ) {
return substr(str_pad($string,$length,$filler,$typ),0,$length);
}
Gruß
Andre
php::bar PHP Wiki - Listenarchive