How to read two fields in a file

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
g_p
Forum Newbie
Posts: 13
Joined: Sun Jan 25, 2009 9:49 am

How to read two fields in a file

Post by g_p »

Hello i would like to read from a file.txt the fields it contains

e.g.
John teacher
George doctor
Maria lawer

I have to read two strings which are seperated by a " " space.

May you please tell me, how can i open and read the file?

Thanks
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: How to read two fields in a file

Post by requinix »

fopen to open the file, fread to read from the file, and fclose to close the file.
Post Reply