jaimeschu Posted June 29, 2009 Share Posted June 29, 2009 Hi, I am not even sure where to post this, so please excuse the randomness. Anyway, I am dealing with using form data and writing it to a flat text file. Everything works as it should, except that I am having issues mapping the data where I want it to go in the text file. For example, I want the information from the first name field to start at position 1, and I want last name information to start at position 30, no matter what. I have been looking everywhere. Anyone have a clue for me? ??? Many thanks in advance. Link to comment https://forums.phpfreaks.com/topic/164152-flatfile-formatting/ Share on other sites More sharing options...
mattal999 Posted June 29, 2009 Share Posted June 29, 2009 We need to see some code, otherwise we can't see where you're going wrong. Post the code for your submission and the form where you get the data from please. Link to comment https://forums.phpfreaks.com/topic/164152-flatfile-formatting/#findComment-865911 Share on other sites More sharing options...
rhodesa Posted June 29, 2009 Share Posted June 29, 2009 you will want to do something like this: $first_name = str_pad(substr($first_name,0,30),30); substr() will shorten it if it's too long, then str_pad() will add whitespace to the right side to fill it to 30 Link to comment https://forums.phpfreaks.com/topic/164152-flatfile-formatting/#findComment-865914 Share on other sites More sharing options...
MatthewJ Posted June 29, 2009 Share Posted June 29, 2009 Try searching for tips/tutorials on "fixed width" text files. I would guess though that most suggestions will look like the one by rhodesa. Link to comment https://forums.phpfreaks.com/topic/164152-flatfile-formatting/#findComment-865927 Share on other sites More sharing options...
jaimeschu Posted June 29, 2009 Author Share Posted June 29, 2009 THANK YOU! that may have done the trick. I ran a test on one line and so far so good. I will let you know how it all pans out. Thanks again for your quick response. I had been googling for days. Link to comment https://forums.phpfreaks.com/topic/164152-flatfile-formatting/#findComment-865930 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.