473,379 Members | 1,379 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,379 software developers and data experts.

find EOF in text file

13
hi guys

i need help, my situation: i need to find EOF in my text file and when it is not present it will display a prompt.
Jul 17 '07 #1
5 3822
dafodil
392 256MB
Heres how you can detect the end of file from a file....
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. $file = fopen("test.txt","r");
  3.  
  4. while(!feof($file))
  5.   {
  6.   //your statements here....
  7.   }
  8. echo "end of file!";
  9. fclose($file);
  10. ?>
  11.  
Jul 17 '07 #2
kid
13
sir how can i check the file if it has a EOF? that is my major problem.

sample data A:

a,b,c,d

Sample data B:

a,b,c,d
EOF


if sample data A has no EOF the program must stop. need help pls.
Jul 17 '07 #3
dafodil
392 256MB
sir how can i check the file if it has a EOF? that is my major problem.

sample data A:

a,b,c,d

Sample data B:

a,b,c,d
EOF


if sample data A has no EOF the program must stop. need help pls.
You mean a text EOF, I thought you are detecting the last part if it is already End OF File....
Jul 17 '07 #4
dafodil
392 256MB
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. $t="";
  3. $file = fopen("test.txt","r");
  4.  
  5. while(!feof($file))
  6.   {
  7. $t=fgets($file). "<br />";
  8.  
  9. if($t=="EOF"){
  10. echo "EOF";
  11. }
  12.  
  13.   }
  14. fclose($file);
  15. ?>
  16.  
As you can see the code above will read the file line by line...
You should write the text EOF at the end of the file in one line....
If it detects it, it displays EOF....
Jul 17 '07 #5
kid
13
thank you so much!!! that works!
Jul 17 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Xah Lee | last post by:
suppose you want to do find & replace of string of all files in a directory. here's the code: ©# -*- coding: utf-8 -*- ©# Python © ©import os,sys © ©mydir= '/Users/t/web'
5
by: Tim Eliot | last post by:
Just wondering if anyone has hit the following issue and how you might have sorted it out. I am using the command: DoCmd.TransferText acExportMerge, , stDataSource, stFileName, True after...
7
by: Yongsub Eric Shin | last post by:
Hi. I'm just a beginner in ASP.Net. I started writing codes and I keep on getting this Runtime Error page, where it says "Description: An application error occurred on the server. The current...
2
by: Paul | last post by:
Can anyone show me a good refined way to find and replace a portion of text held in a text file held on a web server? Thanks in Advance
3
by: TOXiC | last post by:
Hi everyone, First I say that I serched and tryed everything but I cannot figure out how I can do it. I want to open a a file (not necessary a txt) and find and replace a string. I can do it...
7
by: mark | last post by:
Hi All, Apologies for the newbie question but I've searched and tried all sorts for a few days and I'm pulling my hair out ; Please feel free to teach me to suck eggs because it's all new to me...
3
by: =?Utf-8?B?R3JlZyBN?= | last post by:
Hello, I'm running an asp.net, intranet web application using .net framework 1.1 on IIS5.1 / 6.0. Through the web application, I would like to press a button on the web page, have another window...
7
by: kushaldutt | last post by:
Hi all, I am having trouble finding and replacing text in a xml file. My issue is I have to find a text in a xml file and change it to some other text. But the text in some element tag for ex:...
2
by: Perl Beginner | last post by:
Hi, Is there a way to find a line in a text file that starts with a forward slash? This is how i find a line in text file that starts with a word and then print that line to another text file: ...
2
by: karinmorena | last post by:
I'm having 4 errors, I'm very new at this and I would appreciate your input. The error I get is: Week5MortgageGUI.java:151:cannot find symbol symbol: method allInterest(double,double,double)...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.