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