text file into array? (NOOB ASKING)

Any questions involving matching text strings to patterns - the pattern is called a "regular expression."

Moderator: General Moderators

Post Reply
afbase
Forum Contributor
Posts: 113
Joined: Tue Aug 15, 2006 1:29 pm
Location: SoCAL!!!!

text file into array? (NOOB ASKING)

Post by afbase »

the syntax of my text file i would like to make into an array is 'company name' ten spaces 'ticker symbol' ten spaces 'stock exchange traded on' ten spaces, ie:

Code: Select all

1838 Bond Debenture Trading Fd          BDF          NYE
I was wondering how i can convert this to an array...

Look if this is too easy of a question, forward me to someone that will help or atleast give pointers... thanks?????
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

PHP Filesystem: file(), fopen(), fread(), fclose().
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

your file sounds like it's regularly formatted, which means you don't need regex when file(), a loop and substr() will do just fine.
afbase
Forum Contributor
Posts: 113
Joined: Tue Aug 15, 2006 1:29 pm
Location: SoCAL!!!!

I finally have my array!!!

Post by afbase »

ok, thanks to feyd and everah, I got some ideas how to build my array. This is just a tidbit of my array

Code: Select all

Array ( [0] => 1838 Bond Debenture Trading Fd [1] => BDF [2] => NYE [3] => 1st Tr 4 Corners Snr Fl Rt [4] => FCT [5] => NYE [6] => 1st Trust Aberdeen
This array is very long and i was wondering how I could group this array into three's. Eventually i'm going to use this array to insert into a mysql database.

I figured count() might help but not exactly sure about it.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

During each iteration of a line create a temporary array with that line's values. Store that resulting array into your collection array.
afbase
Forum Contributor
Posts: 113
Joined: Tue Aug 15, 2006 1:29 pm
Location: SoCAL!!!!

sweeT!!!!

Post by afbase »

I just got it working to where i can start inserting data into mysql!!!!! thanks
Post Reply