Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

39,877 questions

51,801 answers

573 users

How to read text file with PHP

3 Answers

0 votes
echo readfile("e:/numbers.txt");


/*
run:

1.0 3.0 5.0 7.0 9.0 11.0 13.0 15.0 17.0 19.0 65
 
*/

 



answered Dec 1, 2015 by avibootz
0 votes
echo readfile("numbers.txt"); // file is in the same directory as .php file


/*
run:

1.0 3.0 5.0 7.0 9.0 11.0 13.0 15.0 17.0 19.0 65
 
*/

 



answered Dec 1, 2015 by avibootz
0 votes
$f = fopen("e:/numbers.txt", "r") or die("Error open file!");
echo fread($f, filesize("e:/numbers.txt"));
fclose($f);

/*
run

1.0 3.0 5.0 7.0 9.0 11.0 13.0 15.0 17.0 19.0 

*/

 



answered Dec 3, 2015 by avibootz

Related questions

1 answer 172 views
172 views asked Jul 17, 2017 by avibootz
2 answers 265 views
1 answer 249 views
2 answers 283 views
283 views asked Jan 4, 2021 by avibootz
1 answer 195 views
...