PHP Questions Home
Categories
Arrays
Files
Forms
Creating PDFs
PHP Errors
Functions
Images
MySQL
Numbers
Others
Strings
Website

PHP Forums
Forums Index
MySQL Forum
PHP Forum
Flash/Actionscript
Javascript
Web design

More PHP
PHP Functions
Top Questions
Ask a Question
PHP Interview Questions
PHP Jobs
Ecommerce
IT Questions
Business Websites

Sponsors

sponsor ad
My Salary
PHP Developer Salary
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

More files PHP Questions

I am trying to find the most recent directory that I am working in. example http://www.mysite.com/apples/index.php how do I get php to find the directory "apples" so I can make it a directory

Hello, I have a php file that has octet binary numbers in it. How can I see the actual wording? This is an example of how it look: 00111010 11010010 And so on.

How do i keep my site menu in one file?

How can I view a Word document in a PHP page?

What does file_get_contents do?



Custom Search