Click to See Complete Forum and Search --> : show TXT into php


izlik
05-16-2007, 12:31 PM
hey.

i have a program that updates a .txt file with loginformation. i wonder if i somehow can make a .php file include the contents of a .txt into the php file when the page is loaded so it's displayed.

Charles
05-16-2007, 12:59 PM
<?php include 'some-filename.txt' ?>

izlik
05-16-2007, 01:01 PM
ow it works with include? i tryed it but i most have done someting wrong :) thanks, goan try again.

hastx
05-16-2007, 01:06 PM
The easiest way is probably file_get_contents()


$text = file_get_contents('filename.txt');
echo "$text";


or you could put the lines of the file into an array to expand your ability to work with the data


$lines = file('filename.txt');
foreach ($lines as $line){
echo "<p>$line</p>";
}