note 27322 added to function.str-pad

From: Date: Mon, 02 Dec 2002 08:22:43 +0000
Subject: note 27322 added to function.str-pad
Groups: php.notes 
Request: Send a blank email to php-notes+get-40236@lists.php.net to get a copy of this message
Basically, *all* of you guys have a 'long' way of padding text with html tags (which includes &nbsp;) You dont even have to do a str_replace... try the following code and this will work with ANY html tag there is out there and you don't have to worry about tag character lengths so on and so forth: <? $text = "This is pretty interesting!"; $pad_string = "&nbsp;"; //Pad text on both sides $text = str_pad($text, strlen($text)+(20*strlen($pad_string)), $pad_string, STR_PAD_BOTH); print $text." Dont you think?"; ?> Will produce: This is pretty interesting! Dont you think? Cheers, Fahad -- http://www.php.net/manual/en/function.str-pad.php http://master.php.net/manage/user-notes.php?action=edit+27322 http://master.php.net/manage/user-notes.php?action=delete+27322 http://master.php.net/manage/user-notes.php?action=reject+27322

« previous php.notes (#40236) next »