0

i am opening a file using fopen() and that works fine. from there i want to print out the contents of the file....cant seem to get it to work. here's what i've tried so far.

$file = fopen("order_log_text.txt", "r+");

	echo $file[0];

	/*foreach ($file as $field)
	{
		echo $field;
	}*/

there is only one line in the text file and it is the first line. when i run this code i get no errors, but i also dont get any output on the screen. any help would be greatly appreciated!

2
Contributors
1
Reply
4
Views
10 Years
Discussion Span
Last Post by spincycle
0

PHP has a function that dumps the contents of a file into an array.

$file = fopen("order_log_text.txt", "r+");

# could be

$file = file("order_log_text.txt");
echo "<pre>";
print_r($file);
echo "</pre>":

if you want to continue to write or read on an open file use fwrite() or fread on the open file resourse.

$fp = fopen("filename","r")
$string = fread($fp, filesize("filename"));
echo $string;
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.