kieranbarnes Independent PHP, WordPress & CubeCart Programmer

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

  1. [Snippet] Create a large file in Linux
    Need to create a large file? For disk speed tests? Or space tests? This will...
  2. Detecting MIME types in PHP
    Detecting MIME types in PHP used to be hellish. Use the mime_content_type function I hear...
  3. PHP Export as CSV
    A client recently requested an option to extract search results from their PHP application as...
  4. Sorting a multidimensional array
    PHP's sort() or asort() functions are only single dimensional. What happens when you need to...
  5. Fixing cPanel File Permissions
    Sometimes users mess with their own file permissions that they no longer work. They will...

Filed under: PHP Leave a comment
Comments (0) Trackbacks (0)

No comments yet.


Leave a comment

(required)

No trackbacks yet.