How to remove skip empty line when I read a file?

There are a load of ways you could clean up the array but I like this one.

There are a load of ways you could clean up the array but I like this one: $fileArray = array_values(array_filter($fileArray, "trim")).

Yeah this is like trim, but in fact when I browse the array I get a Notice: Undefined at the position where the empty line was before... – markzzz Apr 23 at 22:34 Iterate over the array with foreach() instead of a for() loop and you should be OK. (added extra line which should allow a for to work too – James C Apr 23 at 22:38 Yeah, I miss the array_values function! Nice one!

Thanks – markzzz Apr 23 at 22:49 P.S. Why do you prefeer empty at trim? – markzzz Apr 23 at 22:49 1 empty() will return true/false depending on whether the string (line) is empty.Trim() will only ever return a trimmed string so for " " it'd return "" and we'd still have an empty line – James C Apr 23 at 22:55.

FILE_SKIP_EMPTY_LINES really only skips empty lines. If you have spaces or tabs or other whitespace in it, file() will not consider it an empty line. It doesn't do a trim before checking, it looks if $line=="\n" and only then considers it an empty line.As alternative you could use: $file = array_filter(array_map("trim", file("text.

Txt")), "strlen").

Uhm. So how can I remove whitespace? $fileArray=array_filter($fileArray, "trim");?

– markzzz Apr 23 at 22:24 Almost. See edit. But this will return all lines trimmed, not just for testing.

– mario Apr 23 at 22:27 Uhm, it doenst work! If I tried to see the result with a for, when I delete the value I get an Notice: Undefined offset: – markzzz Apr 23 at 22:31 Use print_r to see results, not a for loop. – mario Apr 23 at 22:33.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions