Reading selected characters from plain text

Codes here !

Moderators: macek, egami, gesf

pickett1987
New php-forum User
New php-forum User
Posts: 1
Joined: Thu Mar 14, 2013 2:02 pm

Reading selected characters from plain text

Postby pickett1987 » Thu Mar 14, 2013 2:11 pm

Hi,

I am trying to read certain characters from a text file which I want to include into a variable. I can make it read the plain text and put each line into an array but this is where I am stuck. Please note, I am only new to php. :)

Below is the structure of the original text. I would like to get the run, file and totals which is 42, then 21. The structure is always the same.

M***** - **** Voluntary Contribution Letter
PRINT RECONCILATION


Run:073 FILE:P073TVCX DATE:Fri Mar 15 02:29:34 2013

STREAM THRESHOLD IMPRESSIONS ACCTS BEGINNING BEG ENDING END
NUMBER ACCOUNT POST ACCOUNT POST
-------------------- --------- ----------- ----------- ------------------- ---- ------------------- ----
1 TO 7 SHEETS 01 42 21 000000000000017 2148 000000000000004 3741
-------------------- --------- ----------- ----------- ------------------- ---- ------------------- ----
TOTAL 42 21

GRAND 42 21

johnj
php-forum Super User
php-forum Super User
Posts: 1805
Joined: Thu Mar 10, 2011 5:07 pm

Re: Reading selected characters from plain text

Postby johnj » Fri Mar 15, 2013 2:42 am

After reading each line from the file, try to use regular expression to do the pattern search and match. Take a look at this example:
http://phillipnb.wordpress.com/2011/03/ ... ns-part-1/


Return to “mySQL & php coding”

Who is online

Users browsing this forum: No registered users and 1 guest

cron