need to create a fixed placement flat-file
Posted: Tue Dec 20, 2005 3:50 pm
I need to build a system that can generate flat-text files with items in fixed positions.
for example:
First Name: position 1 - 99
Last Name: position 100 - 199
Phone Num: position 200-220
etc.
I'd like some suggestions as to what you think would be the best way to tackle this. My first concern is that the length of names, phone numbers etc is going to be variable and I need to account for those differences. I'm not sure of a php function that will allow me to continue a string at a pre-defined placement but if there is such a thing...that would be my golden key. My alternative (as I see it) is to figure out the length of the item, then add spaces until I hit the next spot which is not the option I want to pursue as there are a TON of 'fields' that I need to account for.
If any of you have done something like this, or know of a good way to tackle this project, please share as I really don't want to have to 'hard-code' this for all of the fields that are in this monstrosity.
for example:
First Name: position 1 - 99
Last Name: position 100 - 199
Phone Num: position 200-220
etc.
I'd like some suggestions as to what you think would be the best way to tackle this. My first concern is that the length of names, phone numbers etc is going to be variable and I need to account for those differences. I'm not sure of a php function that will allow me to continue a string at a pre-defined placement but if there is such a thing...that would be my golden key. My alternative (as I see it) is to figure out the length of the item, then add spaces until I hit the next spot which is not the option I want to pursue as there are a TON of 'fields' that I need to account for.
If any of you have done something like this, or know of a good way to tackle this project, please share as I really don't want to have to 'hard-code' this for all of the fields that are in this monstrosity.