On Tue, 19 Mar 2002, Analysis & Solutions wrote:
> On Tue, Mar 19, 2002 at 09:40:17PM +0100, Jan Grafström wrote:
>> I have read several tricks of how to remove white spaces but how to create
>> them?
>>
>> product    items    price    amount
>> book        2            25            50
>> cd-rom     3            15            45
> 
> I'd avoid using tabs due to them being rendered as different widhts on 
> different machines/programs/etc.  sprintf() is the way to go.
>  . . .
> echo "$product" . sprintf("%$padding.s%6.2f%7.2f", $items, $price, 

This (sprintf) is the right answer. The various answers involving \t and
chr(9) are not that helpful for two reasons:

First of all, they won't let you right-align or decimal-align, which is
standard in columns of numbers.

Secondly, many mail clients just render tabs as spaces, resulting in a
cluttered mess.

Of course, some mail clients insist on using proprotionally-spaced fonts
for plaintext messages, but even with them, the columns will be roughly
similar if not perfectly smooth. Many proportionally-spaced fonts add
extra room around the 1 in order to make it as logically wide as the other
numbers.

If visual aesthetics are very important, send a multipart/mixed message 
with a text/plain and a text/html component.

miguel


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

Reply via email to