Click to See Complete Forum and Search --> : Space Stripping


chestertb
01-29-2007, 05:38 AM
Ok. I'm stumped.

This
$t++;
$invc[$t] = "Invoice Date:.......".$pdate;
$t++;
$invc[$t] = "Invoice Number:.....".$cart;
prints as
Invoice Date:.......02-11-2006
Invoice Number:.....1053

While this
$t++;
$invc[$t] = "Invoice Date: ".$pdate;
$t++;
$invc[$t] = "Invoice Number: ".$cart;
loses the padding spaces and prints as
Invoice Date: 02-11-2006
Invoice Number: 1053

though not all of them... it seems to condense multiple spaces to a single space... so it looks like this is a "feature" of php.

How do I work around this?

Thanks
CTB

NightShift58
01-29-2007, 06:02 AM
This:$t++;
$invc[$t] = "Invoice Date: ".$pdate;
$t++;
$invc[$t] = "Invoice Number: ".$cart;could be:$invc[++$t] = "Invoice Date:    ".$pdate;
$invc[++$t] = "Invoice Number:  ".$cart;Adjust the number of "non-breaking spaces" ( ) to the amount needed.

chestertb
01-29-2007, 06:10 AM
Yup. Just had that light bulb moment.
Thanks.

The construct has to serve two purposes... it is a text email, AND displays on screen.

I guess I'll just have to create it twice.

Thanks for your help Nightshift. Much appreciated.
Cheers
CTB

MrCoder
01-29-2007, 06:10 AM
You could also enclose your text in <pre></pre> tags.

chestertb
01-29-2007, 06:28 AM
Simple works.
<pre>
Thanks Mr Coder. Solution rocks!
Sometimes it's too easy to overlook the simple in favour of being way more complex.
Much appreciated.
CTB

MrCoder
01-29-2007, 06:52 AM
A complex thing is only complex because people dont know how simple it is.

Glad I could help.