Skipping blank lines with strpos in PHP -


I want to read a line and if it is empty, then leave it to work, but I'm studying The text file that starts with three empty lines and it only leaves one of them, how can I leave three blank lines at the beginning of the file and all other blank lines at the beginning of the file?

  $ handle = fopen ("testlog.log", "r"); If ($ handle) {while (! (Fif ($ handle)) {$ buffer = fgets ($ handle, 4096); $ Pos = strpos ($ buffer, '/ n'); if ($ pos == false) {// do stuff}}  

Edit

Here's the full code I know I'm messing up ...

There are several delimiters in the log file, what is a way of harvesting the variable?

the log file:

  & lt ;? Php $ handle = fopen ( "testlog $ ($ (Handle $ ($ (handle $); $ Conn = mysql_connect ("localhost", "user", "pass"); mysql_select_db ("castleot_crawlerlogs", $ Conn); Handle)) {$ buffer = fgets ($ handle, 4096) ); $ Buffer 0 = fast ($ handle, 4096); $ buffer 1 = fast ($ handle, 409); $ buffer 2 = fast ($ handle, 409); $ buffer 3 = fast ( $ Handle, 4096); $ Buffer 4 = Fast ($ Handle, 4096); $ Buffer 5 = Fast ($ Handle, 4096); $ Pos = strpos ($ buffer, '\ n'); if ( $ pos === false) {list ($ version, $ Versiondata) = explode ( "", $ buffer 0); list ($ board, $ Boarddeta) = explode ( "---", $ buffer 1); list ($ Ability friend, $ abfdata) = explosion (":", $ buffer 2); List ($ katmanyam, $ abedata) = explosion (":", $ buffer 3); List ($ mana, $ manadata) = explosion (":", $ buffer4); List ($ secret, $ secretdata) = explosion (":", $ buffer 5); $ Secret = "en_mycut"; $ Sql ​​= "Logtst ($ version, $ board, $ capacity friends, $ Kshmtanenmi, enter $ minds, $ secret) VALUES ( '". $ Versiondata. "'". $ Boarddata. " ' ". $ .. abfdata" ',' "$ abedata" ',' "$ manadata" ',' "$ secretdata" ') "..... $ Edition echoes.": ". $ Versiondata." & Lt; Br> ". $ Board.": ". $ BoardData." & Lt; Br> "$ Ability Friend.": ". $ Abfdata." & Lt; Br> ". $ Ability.": "$ Abedata." & Lt; Br> ". $ Mana.": ". $ Manadata." & Lt; Br> "$ Secret.": ". $ Secretdata." & Lt; Br <, mysql_query ($ sql, $ conn) or die (mysql_error ());}}} {echo "file load failed.";} Fclose ($ handle);? & Gt;  < / Pre> 

Try this:

  $ handle = fopen ("testlog.log "," r "); if ($ handle) {while (! (Fif ($ handle)) {$ buffer = fgets ($ handle, 4096); if (! empty ($ buffer) & amp; amp; $ buffer [0]! == "\ n") {// do stuff}}}  

Comments

Popular posts from this blog

java - org.apache.http.ProtocolException: Target host is not specified -

java - Gradle dependencies: compile project by relative path -

ruby on rails - Object doesn't support #inspect when used with .include -