Uberfuzzy
Uberfuzzy

Reputation: 8372

trim vs FILE_IGNORE_NEW_LINES

I've got a file of 680,000 IDs (one per line) I have to get into an array.

I'm loading it with the file() function right now.

I'm wondering which of these 2 methods is faster and/or better (and why):

Upvotes: 1

Views: 3134

Answers (1)

Mark Baker
Mark Baker

Reputation: 212442

Almost certainly A... the parameter is there for a reason. B requires an additional function call to array_map(), and additional calls to trim() for every line, plus the additional memory overheads of having that extra character in every array element until you trim them all down again.

Upvotes: 9

Related Questions