Jump to content

Recommended Posts

I want to read a file where there are more than 60 New Line Characters. and this 60 Lines equals to one record so I have to create a reader and writer for that File. If U can also help me on how to make this 60 lines a record. I will be obliged for it.

Ok.. on the assumption that each record is exactly 60 lines, you could do something like the following:

 

$fp = fopen('file.txt', 'r') or die("Could not open file\n");
$line_count = 0;
$record = '';
$records = array();
while (!feof($fp)) {
  $line = fgets($fp);
  $line_count++;
  if ($line_count < 60) {
    # Add to current record
    $record .= $line;
  } else {
    # Completed one record
    $records[] = $record;
    $record = '';
    $line_count = 0;
  }
}

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.