How do I read .txt file and use contents as string variable
Posted: Sat Jan 19, 2008 5:29 pm
Complete and utter noob here, trying to use the contents of input.txt as a string variable
Only snippet I've found that seems to resemble what I need ....
<?php
$filename="input.txt";
$output="";
$file = fopen($filename, "r");
while(!feof($file)) {
$output = $output . fgets($file, 4096);
}
fclose ($file);
echo $output;
?>
So, can I merely use the $output variable to insert a string into my script?
Or is there a better method?
Many Thanks,
Kirk
Only snippet I've found that seems to resemble what I need ....
<?php
$filename="input.txt";
$output="";
$file = fopen($filename, "r");
while(!feof($file)) {
$output = $output . fgets($file, 4096);
}
fclose ($file);
echo $output;
?>
So, can I merely use the $output variable to insert a string into my script?
Or is there a better method?
Many Thanks,
Kirk