Okay, this email is basically an order confirmation email which contains cart contents that is sent to me and the customer. I prefer to send the emails in plain/text so there are no html issues and it is cleaner. Here is an example of the email sent :
Date: Wed Dec 31, 2008 10:41 am
Invoice ID: 5B92BBD94
Coupon: hohoho
IP: 111.111.111.111
<!-- BEGIN CARTITEMS -->
2 W4556 Blue Widgets $62.55 $125.10
<!-- BEGIN CARTITEMS -->
1 f4578f Red Widgets $109.35 $109.35
<!-- BEGIN CARTITEMS -->
1 d45789 Green Widgets $166.05 $166.05
<!-- END CARTITEMS -->
Out of stock items (these will ship separately at no additional charge when.... and so on
The above comes to me in the form of a variable $message and then is sent to myself and the customer in an email. What I want to do is align the cart items in columns. I attempted to do this with tabs, however, I noticed not all email clients insert the tabs (such as outlook express) even when sent in plain/text format.
So, what I think I need to do is use str_pad for each of the items. Removing the tag lines <!-- is no problem at all and can be done with str_replace. How the heck can I go about aligning the items though? There is qty, id, desc, price, and total for each cart item. I'm thinking if I use str_pad somehow for each I can insert a certain number of whitespaces for each by knowing the longest possible string length of each column. I do not even need to figure this out as I know already what these are. So... any help on this. I am pretty quick when it comes to coding, but not familiar with php, what functions are available, or how to go about this.
Any help would be really appreciated.