I'm trying to do something that should be easy, but having problems.
All I want to do is generate a report from a MySQL table, and have it as a plain .txt file. I need the file fixed width, so everything lines up and looks good. I'm going to use the courier font, and it's just going to be a barebones table, but how do I actually get everything to line up, the way a fixed-width file should?
Do I have to build up an array of values padded with spaces to get them the same width? or is there a php function to begin writing at a specific position?
Thanks again for the help!
Take a look at the str_pad
method. E.g.
str_pad('Somevalue', 20, " ", STR_PAD_LEFT);
Will left-pad the string "Somevalue" with spaces, giving
" Somevalue"
Whereas
str_pad('Somevalue', 20);
Will right-pad the string with spaces, giving:
"Somevalue "
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With