Re: printf and unsecable char

From: Date: Tue, 05 Jan 2010 10:41:03 +0000
Subject: Re: printf and unsecable char
References: 1 2  Groups: php.db 
Request: Send a blank email to php-db+get-46768@lists.php.net to get a copy of this message
2010/1/4 Chris <dmagick@gmail.com>: > Jean-Philippe Battu wrote: >> >> Hello >> >> I would like  to print a string formatted on the right side and fill in >> the left side with the unsecable character [&nbsp;] >> >> I read in the printf command I could use : printf( "%#30s" , $mystring ) ; >> to display $mystring string with the character # before (on the left) >> >> and I try to replace # by &nbsp; but I can't find a solution >> >> Do you know the solution to write the command:          printf( >> "%&nbsp;30s" , $mystring ) ; >> or something like that ! > > echo str_repeat('&nbsp;', 30); > > (if I understand what you're trying to do correctly). > > -- > Postgresql & php tutorials > http://www.designmagick.com/ > > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > <?php $mystring = 'Hello, world!'; echo str_replace('#', '&nbsp;', str_pad($mystring, 30, '#', STR_PAD_LEFT)); ?> outputs ... &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Hello, world! -- ----- Richard Quadling "Standing on the shoulders of some very clever giants!" EE : http://www.experts-exchange.com/M_248814.html Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731 ZOPA : http://uk.zopa.com/member/RQuadling

« previous php.db (#46768) next »