Re: str_pad()

From: Date: Thu, 04 Jan 2001 02:43:25 +0000
Subject: Re: str_pad()
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-32599@lists.php.net to get a copy of this message
Try changing this line : $final = str_pad($a, $dif); -- to -- $final = str_pad($a, 60); As that is the length you want it to be! No need for the $dif stuff. Regards, Philip On Wed, 3 Jan 2001, Angel Behar wrote: > 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. > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net >

« previous php.general (#32599) next »