RE: [PHP] How do I make tab spaces in a mail?
| From: | Demitrious S. Kelly | Date: | Tue, 19 Mar 2002 21:35:32 +0000 |
| Subject: | RE: [PHP] How do I make tab spaces in a mail? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-89218@lists.php.net to get a copy of this message | ||
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:danielc@analysisandsolutions.com]
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?
>
> 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.
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 items price amount
<?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