CodeIgniter Forums
how to format text in email body - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: how to format text in email body (/showthread.php?tid=31725)



how to format text in email body - El Forum - 06-29-2010

[eluser]megabyte[/eluser]
i'm trying to create an email receipt for an order.

I'm sending the email as text and not html

I'm trying to pad the columns so that there's space between the name, qty and price.

Unfortunately:

Code:
echo str_pad($input, 20, ' ');

does not work. It only pads the string with a single character.

if I do this:

Code:
echo str_pad($input, 20, '#');

The it pads it, because I'm using an actual character.

Does anyone know how to do this with empty spaces?


how to format text in email body - El Forum - 06-29-2010

[eluser]danmontgomery[/eluser]
http://www.sightspecific.com/~mosh/WWW_FAQ/nbsp.html


how to format text in email body - El Forum - 06-29-2010

[eluser]megabyte[/eluser]
That does not work because the email is a plain text not html email.

I tried it already.

You also test it like this in your browser:

Code:
<?php
header('Content-Type: text/plain');

echo str_pad('test', 50, ' ', STR_PAD_LEFT);
?>


Any other ideas?


how to format text in email body - El Forum - 06-29-2010

[eluser]megabyte[/eluser]
OK, so here's the solution just in case others wanna know.

Code:
echo  str_pad('Test', 100, chr('0x20'));