Reading Files (skipping lines, etc...)
Hey, I have quite a few mods that use files to gather any required information, but I'm having trouble with getting it to skip blank lines properly.
I've tested it and it'll skip the ; fine, just not blank lines - so if you put this in the file. Code:
; blah blahCode:
Menu:PHP Code:
|
Re: Reading Files (skipping lines, etc...)
The file natives return a string containing the new line character '^n', so a blank line is really the string "^n".
So solution: Code:
if( szLine[0] == ';' || !szLine[0] || szLine[0] == '^n' ) continue; |
Re: Reading Files (skipping lines, etc...)
ohhh... I see. So just replace szLine[0] with szLine[0] == '^n'...
PHP Code:
PHP Code:
Thanks for the quick response by the way :) |
Re: Reading Files (skipping lines, etc...)
Well !szLine[0] is essentially checking for an empty string. This would only occur if the last line in the file was a blank line. You could take it out if you want, but just to be safe I would leave it there.
|
Re: Reading Files (skipping lines, etc...)
@shadow: You can use trim(szLine) after fgets().
Quote:
|
| All times are GMT -4. The time now is 22:32. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.