RE: [PHP] function to complete strings with white spaces on the left

From: Date: Mon, 21 May 2001 12:05:19 +0000
Subject: RE: [PHP] function to complete strings with white spaces on the left
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-53700@lists.php.net to get a copy of this message
untested! <? if (strlen($word) < 17) { $padding = 17-strlen($word); $word .= str_repeat(' ', $padding); unset($padding); } ?> The reason for the if statement is that str_repeat will produce an error if 17-strlen($word) <= 0 and that'll break your script....of course you could remove the if state if you're positive the # of characters in $word never exceeds 16. Sincerely, Craig Vincent

« previous php.general (#53700) next »