skip to Main Content
How To Read The Text File Using PHP

How to read the text file using PHP

How to read the text file using PHP. Many times we need to store some data in the text file and read the text file. So, today we are learning how we can read the text file.

Let’s see it’s too easy to read the text file using PHP like below.

$file_handle = fopen("pathtofile.txt", "r");
$content = "";
while (!feof($file_handle)) {
    $content[] = fgets($file_handle);
}
fclose($file_handle);

echo '<pre>';
print_r($content);
exit;

Just set the text file path that you want to read.

 

Saroj

I am a web designer and developer part-time blogger. Write something on some free time. Find my every day thought here :)

Leave a Reply

Your email address will not be published. Required fields are marked *

Back To Top