Reputation: 8372
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):
FILE_IGNORE_NEW_LINES
parameterarray_map('trim')
on that arrayUpvotes: 1
Views: 3134
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