By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,747 Members | 2,039 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,747 IT Pros & Developers. It's quick & easy.

ignoring comment line on the text file.

P: 44
hi People
books .txt
to sir with love
the punisher
#php Bible

this is text file that i am reading from.i read these files into an array after that i wipe the content of the file after i push the content of the file to the
text file line by line cause i want to write the specific line and sort.

so my problem is when i write bag to the text file it push all the commented file at the bottom of the file and this prevent me to read the file after the commented one so anybody help
$your_data = $_POST["book"]

$myArray = file($q."book.txt");

//Open registry file and wipe contents

$fp = fopen($q."book.txt", "w");



//Loop through the registry array

foreach ($myArray as $value)


//Write the sorted contents to registry line-by-line



// Close the registry file


please help me to ignore the commented file.
Feb 7 '08 #1
Share this Question
Share on Google+
1 Reply

Expert 2.5K+
P: 4,258
Please explain your problem a bit more clear, cause I do not understand it fully.
Since you do a sort, of course all commented lines are at the end of the file.

Feb 11 '08 #2

Post your reply

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