Read a file into an array
Posted on July 3, 2007
Here's something that puddled me for a while...
$filename = 'file.txt';
$file_handle = fopen($filename, 'r');
$data = '';
while(!feof($file_handle)){
$data .= fgets($file_handle, 1024);
}
Related posts
- [Snippet] Create a large file in Linux
Need to create a large file? For disk speed tests? Or space tests? This will... - Detecting MIME types in PHP
Detecting MIME types in PHP used to be hellish. Use the mime_content_type function I hear... - PHP Export as CSV
A client recently requested an option to extract search results from their PHP application as... - Sorting a multidimensional array
PHP's sort() or asort() functions are only single dimensional. What happens when you need to... - Fixing cPanel File Permissions
Sometimes users mess with their own file permissions that they no longer work. They will...



