heminfotech Posted March 12, 2007 Share Posted March 12, 2007 HI can anyone help me to find new line character in file. I am not able to get any reference thansk for all your support in advance. Hemal Jivani Quote Link to comment https://forums.phpfreaks.com/topic/42321-solved-new-line-character-in-file/ Share on other sites More sharing options...
btherl Posted March 12, 2007 Share Posted March 12, 2007 Can you tell us why you want to find a new line character? There is probably a more specialized solution for the task you want to do. Quote Link to comment https://forums.phpfreaks.com/topic/42321-solved-new-line-character-in-file/#findComment-205304 Share on other sites More sharing options...
heminfotech Posted March 12, 2007 Author Share Posted March 12, 2007 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. Quote Link to comment https://forums.phpfreaks.com/topic/42321-solved-new-line-character-in-file/#findComment-205306 Share on other sites More sharing options...
btherl Posted March 12, 2007 Share Posted March 12, 2007 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; } } Quote Link to comment https://forums.phpfreaks.com/topic/42321-solved-new-line-character-in-file/#findComment-205325 Share on other sites More sharing options...
heminfotech Posted March 12, 2007 Author Share Posted March 12, 2007 Thanks you very very much its work great I am very much great ful to you. Thanks & Regards Hemal Jivani Quote Link to comment https://forums.phpfreaks.com/topic/42321-solved-new-line-character-in-file/#findComment-205328 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.