Source for file str_pad.php
Documentation is available at str_pad.php
* @version $Id: str_pad.php,v 1.1 2007/09/09 20:39:49 pitlinz Exp $
//---------------------------------------------------------------
* Replacement for str_pad. $padStr may contain multi-byte characters.
* @author Oliver Saunders <oliver (a) osinternetservices.com>
* @param int $type ( same constants as str_pad )
* @see http://www.php.net/str_pad
function utf8_str_pad($input, $length, $padStr =
' ', $type =
STR_PAD_RIGHT) {
if ($length <=
$inputLen) {
$padLen =
$length -
$inputLen;
if ($type ==
STR_PAD_RIGHT) {
$repeatTimes =
ceil($padLen /
$padStrLen);
if ($type ==
STR_PAD_LEFT) {
$repeatTimes =
ceil($padLen /
$padStrLen);
if ($type ==
STR_PAD_BOTH) {
$padAmountLeft =
floor($padLen);
$padAmountRight =
ceil($padLen);
$repeatTimesLeft =
ceil($padAmountLeft /
$padStrLen);
$repeatTimesRight =
ceil($padAmountRight /
$padStrLen);
return $paddingLeft .
$input .
$paddingRight;
trigger_error('utf8_str_pad: Unknown padding type (' .
$type .
')',E_USER_ERROR);
Documentation generated on Thu, 08 Jan 2009 17:48:36 +0100 by phpDocumentor 1.4.0a2