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!

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;
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.