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 %' -20s<br>\n",$algen, $calc_amt, $range);

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

This code: printf("%'-20s %'20s %'-20s<br>\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 %'\ -20s<br>\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

Reply via email to