str_pad()

From: Date: Thu, 04 Jan 2001 03:31:26 +0000
Subject: str_pad()
Groups: php.general 
Request: Send a blank email to php-general+get-32597@lists.php.net to get a copy of this message
Hi !!! I'm running php 4.0.3pl1 and want to "fill" a string to a maximum of 60 characters for formatting purpouses, but looks like I'm missing something because doesn't work the str_pad function , here is the code : $a="123456789012345678901234567890123456789012345"; // 45 character string $leng=strlen($a); if ($leng < 60) { $dif=60-$leng; echo "The difference is : $dif<br>"; $final = str_pad($a, $dif); $fin = strlen($final); echo "Final lenght must be (60) : $fin"; } according to the manual this should add 15 whitespaces to $final, but the result is always 45. I 'll appreciate if some one can help me. Thanks in advance.

« previous php.general (#32597) next »