Re: [PHP] How do I make tab spaces in a mail?

2002-03-19 Thread Thalis A. Kalfigopoulos

On Tue, 19 Mar 2002, [iso-8859-1] Jan Grafström wrote:

 Hi!
 I have read several tricks of how to remove white spaces but how to create
 them?
 
 I wan´t to build a normal textmail like this:
 $message=
 productitemspriceamount
 book22550
 cd-rom 31545;
 
 mail($recipient, $subject, $message, $headers);

I'm assuming you are getting the rows from a DB. So looping through the result set and 
storing each row in $next_row[], you could use the implode() function:

while(exist_more_results){
$next_row=get_next_row();
$next_mesg_line=substr(implode(,$next_row),0,-1).\n;
$mesg.=$next_mesg_line;
}

cheers,
--t.

 
 How do I write to get the tab spaces?
 --
 Regards
 Jan Grafström
 
 sweden
 
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 


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




Re: [PHP] How do I make tab spaces in a mail?

2002-03-19 Thread heinisch

At 19.03.2002  21:40, you wrote:

Hi!
I have read several tricks of how to remove white spaces but how to create
them?

I wan´t to build a normal textmail like this:
$message=
productitemspriceamount
book22550
cd-rom 31545;

take book\t2\t25\t50\n...
\t is TAB \n is LF (or CR\LF) depending on hosts os

mail($recipient, $subject, $message, $headers);

How do I write to get the tab spaces?
--
HTH Oliver


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




Re: [PHP] How do I make tab spaces in a mail?

2002-03-19 Thread Analysis Solutions

On Tue, Mar 19, 2002 at 09:40:17PM +0100, Jan Grafström wrote:
 Hi!
 I have read several tricks of how to remove white spaces but how to create
 them?

 productitemspriceamount
 book22550
 cd-rom 31545

I'd avoid using tabs due to them being rendered as different widhts on 
different machines/programs/etc.  sprintf() is the way to go.

Here's a quick and dirty example of an approach that prints out your 
data to the browser.  You'll need to tweak it to get the values from the 
right variable names and to put the string into a variable rather than 
echoing it, but you get the idea...

pre
product   itemspriceamount
?php

$product = 'catnip';
$items = 5;
$price = .5;
$amount = $items * $price;

$padding = 15 - strlen($product);

echo $product . sprintf(%$padding.s%6.2f%7.2f, $items, $price, 
$amount);

?
/pre


-- 
PHP scripts that make your job easier
  http://www.analysisandsolutions.com/code/
 SQL Solution  |  Layout Solution  |  Form Solution
 T H E   A N A L Y S I S   A N D   S O L U T I O N S   C O M P A N Y

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




RE: [PHP] How do I make tab spaces in a mail?

2002-03-19 Thread Demitrious S. Kelly

With less preach and more answer 

Using chr(9) will give you a tab

?php
echo 'pre';
echo 'TAB'.chr(9).'TAB'.chr(9).'TAB';
echo '/pre';
?

cheers
-Original Message-
From: Analysis  Solutions [mailto:[EMAIL PROTECTED]] 
Sent: Tuesday, March 19, 2002 1:29 PM
To: PHP List
Subject: Re: [PHP] How do I make tab spaces in a mail?

On Tue, Mar 19, 2002 at 09:40:17PM +0100, Jan Grafström wrote:
 Hi!
 I have read several tricks of how to remove white spaces but how to
create
 them?

 productitemspriceamount
 book22550
 cd-rom 31545

I'd avoid using tabs due to them being rendered as different widhts on 
different machines/programs/etc.  sprintf() is the way to go.

Here's a quick and dirty example of an approach that prints out your 
data to the browser.  You'll need to tweak it to get the values from the

right variable names and to put the string into a variable rather than 
echoing it, but you get the idea...

pre
product   itemspriceamount
?php

$product = 'catnip';
$items = 5;
$price = .5;
$amount = $items * $price;

$padding = 15 - strlen($product);

echo $product . sprintf(%$padding.s%6.2f%7.2f, $items, $price, 
$amount);

?
/pre


-- 
PHP scripts that make your job easier
  http://www.analysisandsolutions.com/code/
 SQL Solution  |  Layout Solution  |  Form Solution
 T H E   A N A L Y S I S   A N D   S O L U T I O N S   C O M P A N Y

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



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




Re: [PHP] How do I make tab spaces in a mail?

2002-03-19 Thread mnc

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?

 productitemspriceamount
 book22550
 cd-rom 31545
 
 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