Jump to content

Trying to extract everything from a txt file and store it as a variable???


kevinkhan

Recommended Posts

Im trying to display everthing that is in a txt file in a browser and i want to store all the information in a variable. I tryed this simple code but doesnt work.

Any suggestions??

 

	$source_file = 'scan0001.txt';

$fp_s = fopen($source_file, 'r');

  echo $fp_s;

Use file_get_contents as that was what it was made for:

 

$source_file = 'scan0001.txt';
$fp_s = file_get_contents($source_file);
echo $fp_s

 

If you want to use fopen, look at the examples found at fread.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.