[PHP] grief with printf(), padding and alignment of text

2003-02-11 Thread Robert E. Harvey, M.D.
I'm running PHP 4.2.2 and I'm having trouble with the printf() 
function.  I want to be able to print data in  space padded fields with 
the alpha strings left justified and the numeric strings right 
justified.  For some reason I can't get printf() to pad with spaces.  It 
pads with  -s and right aligns the data

For example this code: printf(%' -20s %' 20s %' -20sbr\n,$algen, 
$calc_amt, $range);

returns this output: Algae 292 very high
which shows no padding.

This code: printf(%'-20s %'20s %'-20sbr\n,$algen, $calc_amt, $range);

returns this output: ---Algae 292 ---very high
which pads only the first and third strings with - and not  and 
right justifies to the right and not left.

This code: printf(%'\ -20s %'\ 20s %'\ -20sbr\n,$algen, $calc_amt, 
$range);

returns this output: Algae 292 very high

with no padding and no justification.

How do I get printf() to work properly?



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] grief with printf(), padding and alignment of text

2003-02-11 Thread Matt
- Original Message -
From: Robert E. Harvey, M.D. [EMAIL PROTECTED]
To: php [EMAIL PROTECTED]
Sent: Tuesday, February 11, 2003 6:21 PM
Subject: [PHP] grief with printf(), padding and alignment of text


 I'm running PHP 4.2.2 and I'm having trouble with the printf()
 function.  I want to be able to print data in  space padded fields with
 the alpha strings left justified and the numeric strings right
 justified.  For some reason I can't get printf() to pad with spaces.  It
 pads with  -s and right aligns the data

 For example this code: printf(%' -20s %' 20s %' -20sbr\n,$algen,
 $calc_amt, $range);

 returns this output: Algae 292 very high
 which shows no padding.

View source, and see what you find there.  You should consider tables or
replacing the spaces with the entity nbsp;



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php