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

From: Date: Tue, 19 Mar 2002 21:29:13 +0000
Subject: Re: How do I make tab spaces in a mail?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-89217@lists.php.net to get a copy of this message
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

« previous php.general (#89217) next »