String padding for a text template

Posted by ndee on Stack Overflow See other posts from Stack Overflow or by ndee
Published on 2010-05-14T07:38:10Z Indexed on 2010/05/14 7:44 UTC
Read the original article Hit count: 180

Filed under:

I'm creating a PDF file from a txt-template with tcpdf ([Example 8][1]). The txt-template looks like this:

SALUTATION  
FIRSTNAME LASTNAME                            
STREET                     CURRENTDATE
SOMEMOREINFORMATION                           MYWEBSITE

I replace those markers with the correct value. So that it would look like this:

Mr.  
John Doe                   
Downingstreet 10           14th May, 2010
[email protected]                                  www.stackoverflow.com

In this example, when I replace the values, the indention of the date is dependent on the length of the street name (which I don't want). I could solve this issue with str_pad but the problem is, I normally use three columns and there are lines which only have content in col1 and col3 as in the last line. How can I solve that problem? Is there something like the "overwrite" function in Word, that when you write, the text just gets overwritten?

Thanks in advance.

© Stack Overflow or respective owner

Related posts about php