mfmondragon Posted January 27, 2007 Share Posted January 27, 2007 hi guys, id like to ask how can i do this:1. the text file should be uploaded by the user (is there any codes you can provide)2. i have a text files that is not comma-delimited, only fixed width. though basically i just need 2 - 3 fields to be imported to the database. (the reason why i need this because of the nature of legacy database we're using... btrieve, that's why i just rely to text files being generated)here's the sample data:XXXXX 1004567 I09890990 DELACRUZ, JUAN 01/09/06XXXXX 1004568 I09890980 DELACRUZ, ROSA 01/09/06XXXXX 1004569 I09890990 DELACRUZ, MALOU 01/09/06XXXXX 1004575 I09890990 DELACRUZ, MARIAN 01/09/06 Quote Link to comment Share on other sites More sharing options...
effigy Posted January 27, 2007 Share Posted January 27, 2007 Based on the format you've given, this will work:[code]<pre><?php // This would really be your file. $data = array( 'XXXXX 1004567 I09890990 DELACRUZ, JUAN 01/09/06', 'XXXXX 1004568 I09890980 DELACRUZ, ROSA 01/09/06', 'XXXXX 1004569 I09890990 DELACRUZ, MALOU 01/09/06', 'XXXXX 1004575 I09890990 DELACRUZ, MARIAN 01/09/06' ); // This would really be a loop through your file. foreach ($data as $line) { $pieces = preg_split('/\s{2,}/', $line); print_r($pieces); }?></pre>[/code] Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.