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?
>
> 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



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

Reply via email to