Load textfiles into vars

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
User avatar
vigge89
Forum Regular
Posts: 875
Joined: Wed Jul 30, 2003 3:29 am
Location: Sweden

Load textfiles into vars

Post by vigge89 »

Ive started with a filemanager, and I need some help with how to load parts of a textfile into vars, an example of how the textfile would look like:

Code: Select all

Selected_name_for_content

Author(name@domain.com)

Source_(http://www.altavista.com_etc)

content, which will be more than one line....
Line two...
Line three...
Line four...
Last line here
I want the name for the content in one var, the author in 1, source in 1 and the content in one. The text will not include any PHP-tags, just text and maybe some links, or other HTML-tags...
User avatar
devork
Forum Contributor
Posts: 213
Joined: Fri Aug 08, 2003 6:44 am
Location: p(h) developer's network

Post by devork »

use the file function i
it returns the fiile with every line as array element ..

Code: Select all

<?php
$file=file("hell.txt");
$file[0]... to count($file);

?>
Post Reply