Any questions involving matching text strings to patterns - the pattern is called a "regular expression."
Moderator: General Moderators
afbase
Forum Contributor
Posts: 113 Joined: Tue Aug 15, 2006 1:29 pm
Location: SoCAL!!!!
Post
by afbase » Fri Aug 18, 2006 2:17 am
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?????
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Fri Aug 18, 2006 2:19 am
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!!!!
Post
by afbase » Fri Aug 18, 2006 12:47 pm
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.
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Fri Aug 18, 2006 12:52 pm
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!!!!
Post
by afbase » Fri Aug 18, 2006 2:53 pm
I just got it working to where i can start inserting data into mysql!!!!! thanks