note 35035 added to function.str-pad

From: Date: Sat, 16 Aug 2003 22:22:46 +0000
Subject: note 35035 added to function.str-pad
Groups: php.notes 
Request: Send a blank email to php-notes+get-54498@lists.php.net to get a copy of this message
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 ---- Manual Page -- http://www.php.net/manual/en/function.str-pad.php Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+35035 Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+35035&report=yes Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+35035&report=yes

« previous php.notes (#54498) next »