Log in

View Full Version : collect data from a .txt file



lankinator
04-03-2007, 07:04 PM
Can someone help me get a page that will collect 2 words from a .txt file and then print the two words on the php page?

The words are all on a separate link in the .txt file

boxxertrumps
04-03-2007, 07:29 PM
<?php
echo file_get_contents("file.txt");
?>
Or, if you wanted to have some info in between them...

<?php
$stuff = file_get_contents("file.txt");
$array = explode(" ",$stuff);
echo "You are ". $array[0] .", correct?";
echo "My name is ". $array[1] .".";
?>
That would give
You are Brian, correct?
My name is Jacob.
with:
Brian Jacob
in the text file