read from file and separate strings

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
duk
Forum Contributor
Posts: 199
Joined: Wed May 19, 2004 8:45 am
Location: London

read from file and separate strings

Post by duk »

i have a file with a lot of lines... all of this lines are in this format...

name surname dd/mm/yy otherinfo otherinfo
name surname dd/mm/yy otherinfo otherinfo
name surname dd/mm/yy otherinfo otherinfo
name surname dd/mm/yy otherinfo otherinfo

what i want to do is read the file, and manipulate line by line inserting into array, when it finds the \n will look for the next line...
i have check explode function, but i just see obtions to explode when it finds something between strings and in this case i don't have nothing...

how can i do this ??
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

I'm not very good at regex so I don't know how to physically break up your string, but what I can tell you is if you open your file with file() then each line will be put into an array element already.
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Post by Weirdan »

duk
Forum Contributor
Posts: 199
Joined: Wed May 19, 2004 8:45 am
Location: London

Post by duk »

that dont result for me...

what that will do is the first array[0] will have all until e find \n what i want is that explode check multiple combinations to result in:

array[0] = 1 string explode with" "
array[0] = 2 string explode with"/"
array[0] = 2 string explode with":"

i think i will need to check 1 by 1..
Post Reply