note 35035 rejected from function.str-pad by didou

From: Date: Tue, 28 Oct 2003 14:51:45 +0000
Subject: note 35035 rejected from function.str-pad by didou
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-59427@lists.php.net to get a copy of this message
Note Submitter: zubfatal ---- the str_pad() function seems to work allright, however it seems you can't add HTML code in the PAD_STR - you can in this function: function new_str_pad($strInput, $intPadLength, $strPadStr = " ", $strPadType = "STR_PAD_LEFT") { if (strlen($strInput) < $intPadLength) { $padLength = intval($intPadLength - strlen(strip_tags($strInput))); switch (strtoupper($strPadType)) { case "STR_PAD_LEFT": case "LEFT": return str_repeat($strPadStr, $padLength) . $strInput; break; case "STR_PAD_RIGHT": case "RIGHT": return $strInput . str_repeat($strPadStr, $padLength); break; default: return str_repeat($strPadStr, $padLength) . $strInput; break; } } else { return $strInput; } } I haven't implemented STR_PAD_BOTH as PAD_TYPE, since i couldn't find a purpose for this. - zubfatal

« previous php.notes (#59427) next »