PHP Questions Home
Categories
Arrays
Files
Forms
Functions
Images
MySQL
Numbers
Others
Strings
Website
Unanswered

PHP Functions
PHP Functions

More PHP
Top Questions
Ask a Question
Sponsors

sponsor ad
Advertise Here

What is the use of file in php?


The file function returns the contents of a file as an array, with one line per element in the array.

For instance, if I have a file that contains this:

Hello
This
Is
My
File

Then this is how the file function returns it:

<?php

$contents 
file("myfile.txt");
print_r($contents);
?>


which prints

Array
(
[0] => Hello
[1] => This
[2] => Is
[3] => My
[4] => File
)



Ask a Question / Comment on this Question and Answer >>>

More files PHP Questions

HOW CAN I VIEW THE WORD DOCUMENT IN THE PHP PAGE
Where is a text file i created kept?
How do I open a file to write content to?
What does file_get_contents do?
How can i upload large files like mp3 songs using php?