note 57116 deleted from function.str-pad by danbrown

From: Date: Sat, 02 Jul 2011 18:56:00 +0000
Subject: note 57116 deleted from function.str-pad by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-181193@lists.php.net to get a copy of this message
Note Submitter: Michal Nazarewicz, min86 at tlen dot pl ---- Re ks: Your function does something different if $padchar is not a chararcter but rather a string. Still, however, private's function may be simplified: <?php function str_pad_right($str, $pad, $len) { return $str . str_pad('', $len, $pad); } function str_pad_left($str, $pad, $len) { return str_pad('', $len, $pad) . $str; } function str_pad_both($str, $pad, $len) { return ($s = str_pad('', $len, $pad)) . $str . $s; } ?>

« previous php.notes (#181193) next »